vc6中进行多行注释和反注释的方法
1、利用工具中自带的按钮实现:
Tools-->Customize-->Add-ins and Macro Files-->将SAMPLE项选中-->Commands-->Category中选择Macros-->在Commands中将CommentOut拖到工具栏,再选中一个Images,点击OK即可。
这种方法是使用/* */进行多行注释的,而且不能全部一次取消,使用起来并不方便。
2、利用VBA 宏实现:
Tools-->Macro-->输入Macro Name-->Edit-->Description-->点击OK,删除刚才生成的代码,贴代码:
'多行注释
Sub Comment()
if Documents.Count = 0 then
exit sub
end if
lTopLine = ActiveDocument.Selection.TopLine
lBottomLine = ActiveDocument.Selection.BottomLine
lInsertPoint = ActiveDocument.Selection.CurrentLine
For I = lTopLine To lBottomLine
ActiveDocument.Selection.MoveTo I, 1
ActiveDocument.Selection.SelectLine
s = ActiveDocument.Selection.Text
if s <> vbCrLf then
s = "//" + vbTab + s
end if
ActiveDocument.Selection.Text = s
Next
if lTopLine = lInsertPoint then
ActiveDocument.Selection.MoveTo lBottomLine, dsEndOfLine
ActiveDocument.Selection.MoveTo lTopLine, 1, dsExtend
else
ActiveDocument.Selection.MoveTo lTopLine, 1
ActiveDocument.Selection.MoveTo lBottomLine, dsEndOfLine, dsExtend
end if
End Sub
'多行反注释
Sub Uncomment()
if Documents.Count = 0 then
exit sub
end if
lTopLine = ActiveDocument.Selection.TopLine
lBottomLine =ActiveDocument.Selection.BottomLine
lInsertPoint = ActiveDocument.Selection.CurrentLine
For I = lTopLine To lBottomLine
ActiveDocument.Selection.MoveTo I, 1
ActiveDocument.Selection.SelectLine
s = ActiveDocument.Selection.Text
while left(s, 1) = " " OR left(s, 1) = vbTab
s = right(s, len(s) - 1)
Wend
if left(s, 3) = "//" + vbTab then
s = right(s, len(s) - 3)
elseif left(s, 2) = "//" then
s = right(s, len(s) - 2)
end if
ActiveDocument.Selection.Text = s
Next
if lTopLine = lInsertPoint then
ActiveDocument.Selection.MoveTo lBottomLine, dsEndOfLine
ActiveDocument.Selection.MoveTo lTopLine, 1, dsExtend
else
ActiveDocument.Selection.MoveTo lTopLine, 1
ActiveDocument.Selection.MoveTo lBottomLine, dsEndOfLine, dsExtend
end if
ActiveDocument.Selection.SmartFormat
End Sub
关闭并保存。
Tools-->Customize-->Commands-->在Category中选择Marcos-->在右侧Commands中拖出刚才生成的两个宏名到工具条上,-->分别选择Images图标。
设置快捷键:Keyboard-->Category中选择Macros,在Commands中选择一个然后设置快捷键即可。
3、转自:http://blog.csdn.net/jiaolongdy/archive/2010/12/30/6106782.aspx
取消/注释的宏,可以用于C++,java,VB
VC内使用方法:
将文件格式更改为dsm,放置于Program Files/Microsoft Visual Studio/COMMON/MSDev98/Macros目录下
打开VC——Customize——add-ins and Macro files
勾选上Comment,然后选择键盘,类别里选择Macros,CustomCommentOut设置好快捷键就可以了
Sub CustomCommentOut()
'DESCRIPTION: 注释/取消注释宏,可处理VB和C++、Java注释
Dim win
set win = ActiveWindow
If win.type <> "Text" Then
MsgBox "This macro can only be run when a text editor window is active."
Else
TypeOfFile = 3
If TypeOfFile > 0 And TypeOfFile < 6 Then
If TypeOfFile > 3 Then
CommentType = "'" ' VB注释
CommentWidth = 1
Else
CommentType = "//" ' C++、java 注释
CommentWidth = 2
End If
StartLine = ActiveDocument.Selection.TopLine
EndLine = ActiveDocument.Selection.BottomLine
If EndLine < StartLine Then
Temp = StartLine
StartLine = EndLine
EndLine = Temp
End If
' 单行
If EndLine = StartLine Then
ActiveDocument.Selection.StartOfLine dsFirstColumn
ActiveDocument.Selection.CharRight dsExtend, CommentWidth
If ActiveDocument.Selection = CommentType Then
ActiveDocument.Selection.Delete
Else
ActiveDocument.Selection.StartOfLine dsFirstText
ActiveDocument.Selection.CharRight dsExtend, CommentWidth
If ActiveDocument.Selection = CommentType Then
ActiveDocument.Selection.CharRight dsExtend
ActiveDocument.Selection.Delete
Else
ActiveDocument.Selection.StartOfLine dsFirstText
ActiveDocument.Selection = CommentType + vbTab + _
ActiveDocument.Selection
End If
End If
' 多行
Else
For i = StartLine To EndLine
ActiveDocument.Selection.GoToLine i
CommentLoc = dsFirstColumn
ActiveDocument.Selection.StartOfLine CommentLoc
ActiveDocument.Selection.CharRight dsExtend, CommentWidth
If ActiveDocument.Selection = CommentType Then
ActiveDocument.Selection.Delete
Else
ActiveDocument.Selection.StartOfLine CommentLoc
ActiveDocument.Selection = CommentType + _
ActiveDocument.Selection
End If
Next
End If
Else
MsgBox("Unable to comment out the highlighted text" + vbLf + _
"because the file type was unrecognized." + vbLf + _
"If the file has not yet been saved, " + vbLf + _
"please save it and try again.")
End If
End If
End Sub
4、转自:http://hi.baidu.com/starloooooove/blog/item/9324343ba0364ee014cecb2a.html
打开记事本,输入如下代码:
Sub CommentBlock()
With ActiveDocument.Selection
'对于当前窗口打开的文档中选中的文本
.ReplaceText "%", "//", dsMatchRegExpB
'在开始位置增加 // 注释
End With
End Sub
Sub UncommentBlock()
With ActiveDocument.Selection
.ReplaceText "%//", "", dsMatchRegExpB
'同样的,去掉在选择文本中开头找到的注释符号
End With
End Sub
安装使用这个宏文件:
1、把这个文件命名为COMMENTMAC.dsm,保存到你的VS安装目录下的O:/VS6/Common/MSDev98/Macros中;
2、在VS6的工具条上按下右键,点击Customize下
1)、ADD-INS and Macro Files属性页,选择COMMENTMAC”;
2)、选择keyboard属性页,category下选Macros,为Commands选择快捷键
vc6中进行多行注释和反注释的方法相关推荐
- VC6中使用高版本系统API的方法
有同学在如鹏论坛提问,在VC6中使用GetListBoxInfo这个API函数的时候编译提示: 'GetListBoxInfo' : undeclared identifier 详见:http://s ...
- IDEA中如何设置文件头注释和方法注释(详解)
文件头注释和方法注释的两种方式 方法一: 文件头注释: 打开File–>Settings–>Editor–>File and Code Templates–>includes– ...
- Source Insight 4.0 快捷键设置多行注释与反注释
步骤一:Options--->Key Assignments,如下图 步骤二:在Command:中输入Edit:comment,会过滤后出现Edit:Comment Lines和Edit:Un- ...
- Source Insight 4.0设置注释与反注释的快捷键
之前有一篇详细的说明Source Insight 4.0:source insight教程:常用设置.快捷键.附带source insight3.5和4的对比 source insight查看函数调用 ...
- IDEA中多行注释及取消注释的快捷键分享
这篇文章主要介绍了IDEA中多行注释及取消注释的快捷键分享,具有很好的参考价值,希望对大家有所帮助.一起跟随小编过来看看吧 1.一次性添加多行注释的快捷键 首先选中要注释区域,然后 ctrl+/ 这个 ...
- 关于eclipse的注释和反注释的快捷键
使用eclipse那么久了额,对注释和反注释的快捷键一直很模糊,现在记下来,方便查看. 注释和反注释有两种方式.如对下面这段代码片段(①)进行注释: private String value; pri ...
- vim编辑器---批量注释与反注释
在使用vim编写代码的时候,经常需要用到批量注释与反注释一段代码.下面简要介绍其操作. 方法一 块选择模式 插入注释: 用v进入virtual模式 用上下键选中需要注释的行数 按Control+v(w ...
- 我们如何在Python中创建多行注释?
When we need to comment on multiple lines/statements, there are two ways to do this, either comment ...
- dev多行注释_Python代码注释的用法和意义
01. 注释的作用 在大多数编程语言中,注释都是一项很有用的功能.在一些简单的程序中只包含Python代码,但随着程序越来越大.越来越复杂,就应在其中添加说明,对你解决问题的方法进行大致的阐述.注释让 ...
最新文章
- 安卓java代码标签_Android实现动态添加标签及其点击事件
- 安卓 通过intent调用系统文件管理器打开指定路径目录
- android wps表格如何设置边框颜色
- linux java获取文件创建时间_Linux查看文件的最初创建时间
- hadoop应用开发技术..._Hadoop
- mysql 注释写法有哪些_mysql的注释有几种写法?
- C++ STL vector详解
- java restlet 教程_Restlet 2.0 边学边写(五)Restlet的POST、PUT和DELETE
- pptx文件怎么打开(ppt兼容包下载)
- 遇到from playsound import playsoundModuleNotFoundError: No module named ‘playsound‘解决办法
- 公司办公提高无线网络质量解决方案
- FTP网络服务器 Xlight+FlashFXP
- Windows Server 2008 R2 WSUS服务器的详细配置和部署
- 利用WireShark分析H264码流
- epub电子书如何用Windows电脑打开?
- ZeroC Ice 暂记
- 【工具使用系列】TeX宏包之绘图宏包pgf/tikz
- OpenCV打开相机
- Mac系统 Terminal终端功能使用方法
- html图片滚动红点_HTML+CSS入门 CSS头像右上角的红点