VC 6.0 快捷键添加/取消注释

来源:互联网 发布:红妍肌活精华露 知乎 编辑:程序博客网 时间:2024/05/21 17:03
取消/注释的宏,可以用于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 winset win = ActiveWindowIf win.type <> "Text" Then  MsgBox "This macro can only be run when a text editor window is active."ElseTypeOfFile = 3If TypeOfFile > 0 And TypeOfFile < 6 ThenIf TypeOfFile > 3 ThenCommentType = "'"' VB注释CommentWidth = 1ElseCommentType = "//"' C++、java 注释CommentWidth = 2End If StartLine = ActiveDocument.Selection.TopLineEndLine = ActiveDocument.Selection.BottomLineIf EndLine < StartLine ThenTemp = StartLineStartLine = EndLineEndLine = TempEnd If' 单行If EndLine = StartLine ThenActiveDocument.Selection.StartOfLine dsFirstColumnActiveDocument.Selection.CharRight dsExtend, CommentWidthIf ActiveDocument.Selection = CommentType ThenActiveDocument.Selection.DeleteElseActiveDocument.Selection.StartOfLine dsFirstTextActiveDocument.Selection.CharRight dsExtend, CommentWidthIf ActiveDocument.Selection = CommentType ThenActiveDocument.Selection.CharRight dsExtendActiveDocument.Selection.DeleteElseActiveDocument.Selection.StartOfLine dsFirstTextActiveDocument.Selection = CommentType + vbTab + _                                        ActiveDocument.SelectionEnd IfEnd If' 多行ElseFor i = StartLine To EndLineActiveDocument.Selection.GoToLine iCommentLoc = dsFirstColumnActiveDocument.Selection.StartOfLine CommentLocActiveDocument.Selection.CharRight dsExtend, CommentWidthIf ActiveDocument.Selection = CommentType ThenActiveDocument.Selection.DeleteElseActiveDocument.Selection.StartOfLine CommentLocActiveDocument.Selection = CommentType + _                                                  ActiveDocument.SelectionEnd IfNextEnd IfElseMsgBox("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 IfEnd IfEnd Sub



原创粉丝点击