在Qt Creator刁俭,eclipse等編輯器中憔狞,都默認(rèn)有注釋代碼的快捷鍵:Ctrl + /部凑。
注釋快捷鍵在程序編程當(dāng)中的作用相當(dāng)明顯鲫骗,提高了編程效率锁孟。VC++6.0是以VB為腳本來配置的孽尽。
首先硬鞍,找到VC++6.0的安裝路徑呼奢,假設(shè)在:D:\Program Files (x86)\Microsoft Visual Studio 6.0化戳,那么進(jìn)入到Common\MSDev98\Macros目錄下单料,全路徑為:D:\Program Files (x86)\Microsoft Visual Studio 6.0\Common\MSDev98\Macros。
在該目錄新建一個(gè)文本文件点楼,并重命名為:comment.dsm扫尖,并打開增加以下內(nèi)容:
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 = "http://" ' 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
此時(shí)打開VC++6.0窗口,以下步驟:
1.打開菜單欄"Tools" -> "Customize" 打開了"Customize"對(duì)話框蟀瞧。
4.在代碼中沉颂,只需要選中代碼或者在光標(biāo)所在行条摸,執(zhí)行快捷鍵"Ctrl + /",進(jìn)行注釋或取消注釋铸屉。