给VC++6.0加快捷注释和取消注释
2015-11-24 16:22
323 查看
首先在根目录下找到你的vc++6.0,我的是在c盘的一个叫MSDev98的文件夹里,打开文件夹后,在Macros文件夹中有下面的文件:
找到之后,先新建一个文本框,并命名为comment.dsm,最开始的时候,我直接把程序粘贴到文本框里,保存后,发现是txt的格式,然后想在属性里改格式,但是没能成功。之后百度过很多转换格式的,包括暴风影音也可以在文件下的工具里转换dsm文件。最后是在无意间看到一个问题的回答,终于解决了问题。
在记事本里面把txt转换成其他格式的方法:另存为的时候,选择保存类型为所有文件,然后在文件名中输入文件名,并输入你要的格式的后缀,比如我输入的是commend.dsm(其实应该是comment
)
在记事本里面输入以下程序,
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 成功后的文件应该是这样的:
之后打开vc++6.0, 工具->定制->附加项和宏文件,选择commend如下:(英文版的类似)
再选择命令,在下拉选项中选择Macros,出现如下的,拖动CustomCommentOut放置在工具栏里
拖动后出现如下界面,选择自己喜欢的方式即可:
出现的效果如下:
这样就大功告成啦
我觉得在这个过程中,网络的资源特别重要,不懂得多在网上查找,多看一些资料和回答,让我对一个我不清楚的问题认识的更清楚,印象也更深刻。
找到之后,先新建一个文本框,并命名为comment.dsm,最开始的时候,我直接把程序粘贴到文本框里,保存后,发现是txt的格式,然后想在属性里改格式,但是没能成功。之后百度过很多转换格式的,包括暴风影音也可以在文件下的工具里转换dsm文件。最后是在无意间看到一个问题的回答,终于解决了问题。
在记事本里面把txt转换成其他格式的方法:另存为的时候,选择保存类型为所有文件,然后在文件名中输入文件名,并输入你要的格式的后缀,比如我输入的是commend.dsm(其实应该是comment
)
在记事本里面输入以下程序,
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 成功后的文件应该是这样的:
之后打开vc++6.0, 工具->定制->附加项和宏文件,选择commend如下:(英文版的类似)
再选择命令,在下拉选项中选择Macros,出现如下的,拖动CustomCommentOut放置在工具栏里
拖动后出现如下界面,选择自己喜欢的方式即可:
出现的效果如下:
这样就大功告成啦
我觉得在这个过程中,网络的资源特别重要,不懂得多在网上查找,多看一些资料和回答,让我对一个我不清楚的问题认识的更清楚,印象也更深刻。
相关文章推荐
- ie6 注释引起的问题
- 编写Ruby代码注释时需要注意的一些问题
- Ruby教程之注释、变量声明以及数组操作
- 代码中到底应不应当写注释?
- C#实现为类和函数代码自动添加版权注释信息的方法
- 不要小看注释掉的JS 引起的安全问题
- C#注释的一些使用方法浅谈
- J2SE1.5 注释语法
- c#中xml文档注释编译dll引用到其它项目示例
- 解决在SQL脚本中的注释引起的奇怪问题
- javascript中的注释使用与注意事项小结
- perl中单行注释和多行注释使用介绍
- 详解Ruby语言中的注释用法与中文编码问题
- Bash Shell 注释多行的几种方法
- Oracle 查询表信息获取表字段及字段注释
- ASP.NET Web API如何将注释自动生成帮助文档
- Shell脚本注释写法
- python访问类中docstring注释的实现方法
- 使用正则表达式匹配tsql注释语句
- Python文件去除注释的方法