但是在VC6.0中,最不舒服的就是注释时,可惜VC6.0没有设置注释。

 

从网上发现很好的解决方案,嘻嘻,又可以与Eclispe一样喽……

以下为转载——转载地址:http://blog.csdn.net/gzshun/article/details/7782458

 

在Qt Creator,eclipse等编辑器中,都默认有注释代码的快捷键:Ctrl + /。

注释快捷键在程序编程当中的作用相当明显,提高了编程效率。我在网上找到了一个在VC++6.0工具中添加注释快捷键的方法,VC++6.0是以VB为脚本来配置的。

 

首先,找到VC++6.0的安装路径,假设在:D:\Program Files (x86)\Microsoft Visual Studio 6.0,那么进入到Common\MSDev98\Macros目录下,全路径为:D:\Program Files (x86)\Microsoft Visual Studio 6.0\Common\MSDev98\Macros。

在该目录新建一个文本文件,并重命名为:comment.dsm,并打开增加以下内容:

[vb] view plaincopyprint?

  1. Sub CustomCommentOut()  

  2. 'DESCRIPTION: 注释/取消注释宏,可处理VB和C++、Java注释  

  3.     Dim win  

  4.     set win = ActiveWindow  

  5.     If win.type <> "Text" Then  

  6.       MsgBox "This macro can only be run when a text editor window is active."  

  7.     Else  

  8.         TypeOfFile = 3  

  9.         If TypeOfFile > 0 And TypeOfFile < 6 Then  

  10.             If TypeOfFile > 3 Then  

  11.                 CommentType = "'"   ' VB注释  

  12.                 CommentWidth = 1  

  13.             Else  

  14.                 CommentType = "//"  ' C++、java 注释  

  15.                 CommentWidth = 2  

  16.             End If  

  17.            

  18.             StartLine = ActiveDocument.Selection.TopLine  

  19.             EndLine = ActiveDocument.Selection.BottomLine  

  20.             If EndLine < StartLine Then  

  21.                 Temp = StartLine  

  22.                 StartLine = EndLine  

  23.                 EndLine = Temp  

  24.             End If  

  25.             ' 单行  

  26.             If EndLine = StartLine Then  

  27.                 ActiveDocument.Selection.StartOfLine dsFirstColumn  

  28.                 ActiveDocument.Selection.CharRight dsExtend, CommentWidth  

  29.                 If ActiveDocument.Selection = CommentType Then  

  30.                     ActiveDocument.Selection.Delete  

  31.                 Else  

  32.                     ActiveDocument.Selection.StartOfLine dsFirstText  

  33.                     ActiveDocument.Selection.CharRight dsExtend, CommentWidth  

  34.                     If ActiveDocument.Selection = CommentType Then  

  35.                         ActiveDocument.Selection.CharRight dsExtend  

  36.                         ActiveDocument.Selection.Delete  

  37.                     Else  

  38.                         ActiveDocument.Selection.StartOfLine dsFirstText  

  39.                         ActiveDocument.Selection = CommentType + vbTab + _  

  40.                                         ActiveDocument.Selection  

  41.                     End If  

  42.                 End If  

  43.             ' 多行  

  44.             Else  

  45.                 For i = StartLine To EndLine  

  46.                     ActiveDocument.Selection.GoToLine i  

  47.                     CommentLoc = dsFirstColumn  

  48.                     ActiveDocument.Selection.StartOfLine CommentLoc  

  49.                     ActiveDocument.Selection.CharRight dsExtend, CommentWidth  

  50.                     If ActiveDocument.Selection = CommentType Then  

  51.                         ActiveDocument.Selection.Delete  

  52.                     Else  

  53.                         ActiveDocument.Selection.StartOfLine CommentLoc  

  54.                         ActiveDocument.Selection = CommentType + _  

  55.                                                   ActiveDocument.Selection  

  56.                     End If  

  57.                 Next  

  58.             End If  

  59.         Else  

  60.             MsgBox("Unable to comment out the highlighted text" + vbLf + _  

  61.                 "because the file type was unrecognized." + vbLf + _  

  62.                 "If the file has not yet been saved, " + vbLf + _  

  63.                 "please save it and try again.")  

  64.         End If  

  65.     End If  

  66. End Sub  

 

此时打开VC++6.0窗口,以下步骤:

1.打开菜单栏"Tools" -> "Customize" 打开了"Customize"对话框。

2.

 VC++6.0注释快捷键设置_ VC++6.0注释快捷键

3.

 VC++6.0注释快捷键设置_ VC++6.0注释快捷键_02

4.在代码中,只需要选中代码或者在光标所在行,执行快捷键"Ctrl + /",进行注释或取消注释。