美文网首页
C++6.0 添加注释快捷键

C++6.0 添加注释快捷键

作者: 捣蛋大师cat | 来源:发表于2020-04-15 14:42 被阅读0次

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

注释快捷键在程序编程当中的作用相当明显,提高了编程效率。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,并打开增加以下内容:

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 dsFirstColumn
                        ActiveDocument.Selection = CommentType + _
                                        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窗口,以下步骤:

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

1343140645_1602.jpg
1343140667_9081.jpg

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

相关文章

  • C++6.0 添加注释快捷键

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

  • 代码规范

    文件注释 file - File and code templetes -Go File 添加快捷键 函数注释(...

  • python变量与运算符

    一.快捷键 ctrl + / - 快速添加注释和取消注释 ctrl + s - 保...

  • day2-python基础

    一、认识Python 1.常用的快捷键 control+/注释的快捷键,添加或取消注释,删除代码可以将代码注释,方...

  • 2018-09-29 05 day

    一、认识Python 1.常用的快捷键 control+/注释的快捷键,添加或取消注释,删除代码可以将代码注释,方...

  • 2018-09-30 05 day 作业

    一、认识Python 1.常用的快捷键 control+/注释的快捷键,添加或取消注释,删除代码可以将代码注释,方...

  • HTML基础学习-注释

    注释 - 如何在Webstorm中利用快捷键添加注释 -Ctrl+/

  • iOS注释

    1.单行注释:// 快捷键:command+/ 2.多行注释:/**/ 3.给方法添加Quick help注释...

  • day2 基操、数据类型、进制、原码反码补码等

    一 开场白 hello word 二 部分快捷键 注释的快捷键 ctrl+? 添加或取消一行注释ctrl...

  • Android Studio 规范与技巧

    1.方法注释文档 添加方法注释模版快捷键(Preferences-Keymap-Fix doc comment),...

网友评论

      本文标题:C++6.0 添加注释快捷键

      本文链接:https://www.haomeiwen.com/subject/furclqtx.html