注释与反注释Comment/Uncomment selected code in Visual C++ (转)

注释与反注释Comment/Uncomment selected code in Visual C++ (转)[@more@]

看了younker的Comment/Uncomment selected code in Visual C++ 一文后,深有收获。

.NET/develop/read_article.ASP?id=578">http://www.csdn.net/develop/read_article.asp?id=578

我照着文章上的描述做了一个Add-ins,但是toolbar总是只有一个button。uncomment的button不出现,调了一会儿,未成功。后来,我想用宏的方式将younker的代码扒下来。结果居然很容易的就成功了。而且,代码简单方便(有更简单的,告诉我 :-) )。代码如下:

Sub linecomment()
lTopLine = ActiveDocument.Selection.TopLine
lBottomLine =ActiveDocument.Selection.BottomLine
For I = lTopLine To lBottomLine
 ActiveDocument.Selection.MoveTo I, 1
 ActiveDocument.Selection.SelectLine
 s = ActiveDocument.Selection.Text
 s = "//" + s
 ActiveDocument.Selection.Text = s
Next
End Sub

Sub lineuncomment()
lTopLine = ActiveDocument.Selection.TopLine
lBottomLine =ActiveDocument.Selection.BottomLine
For I = lTopLine To lBottomLine
 ActiveDocument.Selection.MoveTo I, 1
 ActiveDocument.Selection.SelectLine
 s = ActiveDocument.Selection.Text
 if left(s,2) = "//" then
 s = right(s, len(s) - 2)
 end if
 ActiveDocument.Selection.Text = s
Next
End Sub

有兴趣的兄弟可以这样做:

1。点击tool->macros...菜单,点击edit进入编辑界面,将上面的两个vbscript程序paste上去,关闭此窗口。

2。点击tool->customize菜单,选择command标签,在下拉框中选择macros,在右边的commands列表中,按住左键直接拖动linecomment到工具条上去,根据提示选择图片或文字注释,lineuncomment同理。

3。大功告成。打开一个c/c++文件试试,是不是很爽?


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752043/viewspace-990187/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10752043/viewspace-990187/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值