悬赏VC的快捷键

eion 2002-01-17 03:17:54
为了大家方便使用VC,现贡献100分,一条一分,先来先领赏,多多益善,现先列举几个



CTRL+空格 ————自动填充变量或函数【注意关闭中英文输入法的切换】
CTRL+SHIFT+空格——显示函数参数
CTRL+TAB ————子窗口之间切换
F9 —————————断点
F10 ————————单步执行【跳过函数】
F11 ————————单步执行【进入函数】
CTRL+F5 ——————运行
F5 ———————— 调试运行
...全文
1863 84 打赏 收藏 转发到动态 举报
写回复
用AI写文章
84 条回复
切换为时间正序
请发表友善的回复…
发表回复
w_j76 2002-07-11
  • 打赏
  • 举报
回复
up
woodwmh 2002-05-09
  • 打赏
  • 举报
回复
up
eion 2002-01-24
  • 打赏
  • 举报
回复
: AdamBear(学习再学习) 

你可以给出些个范例,我下次在出个帖子来征集,先帮忙想个题目
老熊宝宝 2002-01-23
  • 打赏
  • 举报
回复
楼上的所贴的代码不就是VC自带的Macro里的东西吗?不过,注释得还不错。
实际上,还有很多VC做不到的东西必须用宏来做,比如build后给Version自动加1的功能
,等等。象这样列出key map里就有的快捷键,还不如大家来研究一下如何用VBS或自制向导
搞出一点有意义的新功能,大家来动动脑子吧!
eastxing 2002-01-23
  • 打赏
  • 举报
回复
ALT+F9断点窗口
eion 2002-01-23
  • 打赏
  • 举报
回复
Tools->Customize->Keyboard
Help->Keyboardmap里有所有的快捷键(包括自定义的)


CTRL+空格 ———— 自动填充变量或函数【注意关闭中英文输入法的切换】
CTRL+SHIFT+空格—— 显示函数参数
CTRL+TAB ———— 子窗口之间切换
CTRL+F5 —————— 运行
F5 ———————— 调试运行
Ctrl+W------------- 类向导
Ctrl+N------- 新建程序向导
ALT+LeftArrow———— Code auto complate
Ctrl+I—————— 查找
CTRL + G ———— 到……行
Ctrl+Shift+G —— 打开文件
ctrl+shift+f9—— 清除所有断点。
f1 ———————— 帮助
F2 ———— 移动到标记
CTRL + F2 ———— 添加/删除 标记
Alt+ F2———————— 编辑书签
ALT + F2 ———— 标记列表
f3 ———————— 查找下一个
Ctrl+f3: —————— 查找相同字符
F4—————————— 当你编译后切换到下一个Warning/Error处,如果是查找则切换到下一个出现的地方
Ctrl - F4 ———————关闭当前文件/视图;
Alt - F4 ———————关闭程序;
Shift+f5 : ———— 中断调试
F5———————————Debug
Ctrl + F5——————— Run
F7—————————— 编译
Ctrl + F7——————— 编译当前文件
Alt+f7 —————— Setting
alt+f8—————————自动排列选定文本的格式
Alt+F8 ————————自动整理选定的代码
F9 ————————— 断点
Alt+ F9———————— 编辑断点
Ctrl + F10————— 运行到光标处
F10 ———————— 单步执行【跳过函数】
F11 ———————— 单步执行【进入函数】
F12—————————— Ctrl + Num * 的逆

CTRL+SHIFT+f8:—— 列拷贝模式
Ctrl + Num * ————— (F12的逆)返回查找变量定义
Ctrl+Z——————---UNDO
Ctrl+W: —————— 类向导
Home———————— 行首
CTRL+HOME——————— 文件头
End———————— 行尾
ctrl+END——————— 文件未

Ctrl + } ——————— 在有{或}的行, 缺换到它对应的}或{处,用处极大
CTRL + F ——————— 查找
CTRL + H ——————— 替换
CTRL+NUM * ———— 回到上次浏览处【相对于goto define】
alt+ctrl+T—————— 自动显示api或其它
Ctrl + Alt + T
Ctrl + T
Ctrl + W
Ctrl + D
ctrl shift u/ctrl u—— 变换大小写文本
shift + tab ——————选择的代码块左移一个tab
tab ——————————选择的代码块右移一个tab
Ctrl+Shift+} ————— 选中匹配括号中的所用内容,用来拷贝函数体很有用;
Ctrl+Shift+L ————— 删除一行
ctrl+alt+del double—— 关闭vc
Ctrl+K Ctrl+J ———— #if #endif匹配
Ctrl+] ———————— 检查匹配的括号
Ctrl+V ———————— 粘贴
Ctrl+C ———————— 拷贝
CTRL+X———————— 剪切
Ctrl+U———————— 转为小写
Ctrl+Shift+U——————转为大写
Ctrl+L—————————剪切当前行
Ctrl+Shift+L——————删除当前行
ctrl+tab—————— 切换窗口


Alt + 0—————————显示Workspace窗口
Alt + 2—————————显示Watch窗口
ALT+鼠标进行块copy

菜单快捷键:
Open(^O) Save(^S)
Cut(^X) Copy(^C;^Ins) Paste(^V;~Ins)
Undo(^Z) Redo(^Y) Goto(^G) SelectAll(^A)
Find(^F) Replace(^H) FindNext(F3) FindPrevious(!F3)
MoveCursorEachWord(^left;^right) DelToWordEnd(^Del)




俺只有一个宏帮定一个快捷键用来注释的。(/**/)
'------------------------------------------------------------------------------
'FILE DESCRIPTION: New Macro File
'------------------------------------------------------------------------------

Sub CommentOutSelection()
'DESCRIPTION: This macro converts selected source code into a comment.
'TODO: Put macro code here
MyString = ActiveDocument.Selection.Text
ActiveDocument.Selection = "/*" + MyString + "*/"
End Sub

Sub DelCommentToCode()
'DESCRIPTION: This macro converts selected comment into code.

'TODO: Put macro code here
MyString = trim(ActiveDocument.Selection.Text)
If Left(MyString,2)="/*" and Right(MyString,2)="*/" then
ActiveDocument.Selection=Mid(MyString,3,Len(MyString)-4)
else
Msgbox "selected-text is not comment.",vbInformation+vbOkOnly,"Msg"
End If
End Sub
在D:\Program Files\Microsoft Visual Studio\Common\MSDev98\Macros\Mymacros.dsm中增加上面内容。

启动VC,可能会出现一对话框,“是”,TOOLS->Macros->Options->KeyStrocks
为两个宏定义热键。我的是Ctrl+Q,Ctrl+Shift+Q

我自己做了两个宏
一个是自动给函数加注释 用CTRL+~调出来
一个是注释/取消注释选中的代码,用CTRL+/调出来
嘿嘿,特别好用
'-------------------------------------------------------------------------------
'给CSDN的懒人们,这是我自己的两个宏,其实也是修改别人的,你们多在网上找找全都有了
'
'下面的宏用来给函数做注释
'注意一定要把函数头的定义全部选中,如果函数头有多行只选中一行,那么参数是不完整的
'
Sub PrintText( s, newline )
ActiveDocument.Selection = s
if newline then
ActiveDocument.Selection.NewLine
end if
end sub

Function ParseParam( s )
Trim( s )
retpos = InStrRev( s, " " )
ParseParam = Right( s, len( s ) - retpos )
end function

' this is main function
Sub CommentFunction()

Dim win
set win = ActiveWindow

if win.type <> "Text" Then
MsgBox "只有编辑窗口激活才能运行该宏."
else
fun = ActiveDocument.Selection.Text
if len(fun) = 0 then
exit sub
end if

retpos = InStr( 1, fun, " ", vbTextCompare )
retval = Left( fun, retpos - 1)
retval2 = Left( fun, retpos - 1)
lppos = InStr( 1, fun, "(", vbTextCompare )
funcname = Mid( fun , retpos, lppos - retpos )

ActiveDocument.Selection.StartOfLine
ActiveDocument.Selection.LineUp
ActiveDocument.Selection.NewLine
PrintText "////////////////////////////////////////////////////////////////////", TRUE
PrintText "// 函数: " & funcname & "()", TRUE
PrintText "// 目的: ", TRUE
author = "编程八级工"
PrintText "// 参数:", TRUE
fun = Right( fun, Len(fun) - lppos )
pos = 1

have_parameter = false
have_more = true
do while pos > 0 and have_more
pos = InStr( 1, fun, ",", vbTextCompare )
if pos = 0 then
have_more = false
pos = InStr( 1, fun, ")", vbTextCompare )
end if

if pos > 1 then
retval = Left( fun, pos - 1 )
retval = ParseParam( retval )
PrintText "// [" + retval + "] -", TRUE
have_parameter = true
end if

if have_more = true then
fun = Right( fun, Len(fun) - pos )
end if
loop
if have_parameter = true then
PrintText "// ", TRUE
else
PrintText "// -无", TRUE
end if

if retval2 = "void" then
PrintText "// 返回值:" + "[" + retval2 + "] -无", TRUE
else
PrintText "// 返回值:" + "[" + retval2 + "] -", TRUE
end if

PrintText "// ", TRUE
PrintText "// 作者: " & author & ", Created : [" & CDate(Now) & "]", TRUE
PrintText "////////////////////////////////////////////////////////////////////", FALSE
End If
end Sub
'-------------------------------------------------------------------------------
'下面的宏用来注释代码
'
'
Function FileType (ByVal doc)
ext = doc.Name
FileType = 0
pos = Instr(ext, ".")
if pos > 0 then
Do While pos <> 1
ext = Mid(ext, pos, Len(ext) - pos + 1)
pos = Instr(ext, ".")
Loop
ext = LCase(ext)
End If

If ext = ".rc" Or ext = ".rc2" Then
FileType = 7
ElseIf doc.Language = dsCPP Then
FileType = 1
ElseIf doc.Language = dsJava Then
FileType = 2
ElseIf doc.Language = dsIDL Then
FileType = 3
ElseIf doc.Language = dsVBSMacro Then
FileType = 4
ElseIf ext = ".asp" Then
FileType = 5
ElseIf doc.Language = dsHTML_IE3 Or doc.Language = dsHTML_RFC1866 Then
FileType = 6
ElseIf ext = ".def" Then
FileType = 7
Else
FileType = 0
End If

'MsgBox "Ext:" + vbTab + ext + vbLf + "Lang:" + vbTab + doc.Language + vbLf + "Type:" + vbTab +

CStr(FileType)
End Function

Sub CustomCommentOut ()
'DESCRIPTION: Comments out a selected block of text.
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 = FileType(ActiveDocument)
' MsgBox "Type: " + CStr(TypeOfFile)
If TypeOfFile > 0 And TypeOfFile < 6 Then
If TypeOfFile > 3 Then
CommentType = "'" ' VBShit
CommentWidth = 1
Else
CommentType = "//" ' C++ and java style comments

CommentWidth = 2
End If

StartLine = ActiveDocument.Selection.TopLine
EndLine = ActiveDocument.Selection.BottomLine
If EndLine < StartLine Then
Temp = StartLine
StartLine = EndLine
EndLine = Temp
End If

' Single line -- comment at start of text
' have to check for comments at start of line and start of text
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

' Multi-line -- comment at start of line
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("无法注释选中的文本" + vbLf + _
"因为文件格式无法识别." + vbLf + _
"如果文件尚未保存, " + vbLf + _
"请保存后再试.")
End If
End If
End Sub

'下面的宏是纠正了【objectman(编程八级工)】的两个bug的宏代码,一个是注释时不能与上一个函数紧相连,
'另一个是函数的最后一个括号必须与最后一个变量在同一行的问题
Sub PrintText( s, newline )
ActiveDocument.Selection = s
if newline then
ActiveDocument.Selection.NewLine
end if
end sub

Function ParseParam( s )
Trim( s )
retpos = InStrRev( s, " " )
ParseParam = Right( s, len( s ) - retpos )
end function

' this is main function
Sub CommentFunction()

Dim win
set win = ActiveWindow

if win.type <> "Text" Then
MsgBox "只有编辑窗口激活才能运行该宏."
else
fun = ActiveDocument.Selection.Text
if len(fun) = 0 then
exit sub
end if

retpos = InStr( 1, fun, " ", vbTextCompare )
retval = Left( fun, retpos - 1)
retval2 = Left( fun, retpos - 1)
lppos = InStr( 1, fun, "(", vbTextCompare )
funcname = Mid( fun , retpos, lppos - retpos )

ActiveDocument.Selection.StartOfLine
ActiveDocument.Selection.NewLine 'Added by THJ 2002.1.21
ActiveDocument.Selection.LineUp
'ActiveDocument.Selection.NewLine 'Note By Thj 2002.1.21
PrintText "////////////////////////////////////////////////////////////////////",

TRUE
PrintText "// 函数: " & funcname & "()", TRUE
PrintText "// 目的: ", TRUE
author = "eion【电离子】"
PrintText "// 参数:", TRUE
fun = Right( fun, Len(fun) - lppos )
pos = 1

have_parameter = false
have_more = true
do while pos > 0 and have_more
pos = InStr( 1, fun, ",", vbTextCompare )
if pos = 0 then
have_more = false '在此还得先判断是否有回车——唐厚俭2002.1.21
pos = Instr( 1, fun, Chr(13) , vbTextCompare ) '在此先判断是否有回车
if pos = 0 then
pos = InStr( 1, fun, ")", vbTextCompare )
end if
end if

if pos > 1 then
retval = Left( fun, pos - 1 )
retval = ParseParam( retval )
PrintText "// [" + retval + "] -", TRUE
have_parameter = true
end if

if have_more = true then
fun = Right( fun, Len(fun) - pos )
end if
loop
if have_parameter = true then
PrintText "// ", TRUE
else
PrintText "// -无", TRUE
end if

if retval2 = "void" then
PrintText "// 返回值:" + "[" + retval2 + "] -无", TRUE
else
PrintText "// 返回值:" + "[" + retval2 + "] -", TRUE
end if

PrintText "// ", TRUE
PrintText "// 作者: " & author & ", Created : [" & CDate(Now) & "]", TRUE
PrintText "//", FALSE
End If
end Sub
'-------------------------------------------------------------------------------
'下面的宏用来注释代码
'
'
Function FileType (ByVal doc)
ext = doc.Name
FileType = 0
pos = Instr(ext, ".")
if pos > 0 then
Do While pos <> 1
ext = Mid(ext, pos, Len(ext) - pos + 1)
pos = Instr(ext, ".")
Loop
ext = LCase(ext)
End If

If ext = ".rc" Or ext = ".rc2" Then
FileType = 7
ElseIf doc.Language = dsCPP Then
FileType = 1
ElseIf doc.Language = dsJava Then
FileType = 2
ElseIf doc.Language = dsIDL Then
FileType = 3
ElseIf doc.Language = dsVBSMacro Then
FileType = 4
ElseIf ext = ".asp" Then
FileType = 5
ElseIf doc.Language = dsHTML_IE3 Or doc.Language = dsHTML_RFC1866 Then
FileType = 6
ElseIf ext = ".def" Then
FileType = 7
Else
FileType = 0
End If

'MsgBox "Ext:" + vbTab + ext + vbLf + "Lang:" + vbTab + doc.Language + vbLf + "Type:" +

vbTab + CStr(FileType)
End Function

Sub CustomCommentOut ()
'DESCRIPTION: Comments out a selected block of text.
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 = FileType(ActiveDocument)
' MsgBox "Type: " + CStr(TypeOfFile)
If TypeOfFile > 0 And TypeOfFile < 6 Then
If TypeOfFile > 3 Then
CommentType = "'" ' VBShit
CommentWidth = 1
Else
CommentType = "//" ' C++ and java style comments

CommentWidth = 2
End If

StartLine = ActiveDocument.Selection.TopLine
EndLine = ActiveDocument.Selection.BottomLine
If EndLine < StartLine Then
Temp = StartLine
StartLine = EndLine
EndLine = Temp
End If

' Single line -- comment at start of text
' have to check for comments at start of line and start of text
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

' Multi-line -- comment at start of line
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("无法注释选中的文本" + vbLf + _
"因为文件格式无法识别." + vbLf + _
"如果文件尚未保存, " + vbLf + _
"请保存后再试.")
End If
End If
End Sub


xrenwu 2002-01-23
  • 打赏
  • 举报
回复
太好了!!!
hob 2002-01-22
  • 打赏
  • 举报
回复
guanzhu
eion 2002-01-22
  • 打赏
  • 举报
回复
谢谢大家的捧场
最低分1分,然后外加了24分,正好分下去——不多,还望见谅,有时间我再整理,这几天我比较忙
eion 2002-01-22
  • 打赏
  • 举报
回复
Over
截题
dongfa 2002-01-22
  • 打赏
  • 举报
回复
ALT+鼠标进行块copy
eion 2002-01-21
  • 打赏
  • 举报
回复
看来我得100分没白花,估计大家都学了不少了吧?
何时截题? 给个意见
当然,有好的快捷键还可以继续,等我有时间我把他们整理出来
先谢谢大家的捧场!!!!!!!!!!!!!!!!!
vickowang 2002-01-21
  • 打赏
  • 举报
回复
VC6 常用快捷键
常用编辑
包括各种括号{}, [], ()
和Windows的常用编辑快捷键相同


Open(^O) Save(^S)
Cut(^X) Copy(^C;^Ins) Paste(^V;~Ins)
Undo(^Z) Redo(^Y) Goto(^G) SelectAll(^A)
Find(^F) Replace(^H) FindNext(F3) FindPrevious(!F3)
MoveCursorEachWord(^left;^right) DelToWordEnd(^Del)


查找括号匹配
Ctrl + ]

查找#IFDEF,#ENDIF匹配
Ctrl+K(查找和#IFDEF匹配的#ENDIF,往后找), Ctrl+J(查找和#ENDIF匹配的#IFDEF,往前找)
注:J和K的键盘位置和查找方向一致。

大小写转换
块操作。Ctrl+U(转为小写), Ctrl+Shift+U(转为大写)

删除一行
Ctrl+L(剪切当前行), Ctrl+Shift+L(删除当前行)

查找变量定义
F12(Ctrl + Num * 的逆)

返回查找变量定义
Ctrl + Num * (F12的逆)

编辑书签
Alt+ F2

编辑断点
Alt+ F9

ClassWizard
Ctrl+W

编译
F7(编译工程) Ctrl + F7(编译当前文件)

运行
F5(Debug); Ctrl + F5(Run)

显示Workspace窗口
Alt + 0

显示Watch窗口
Alt + 2

格式化块,自动缩进
Alt + F8
objectman 2002-01-21
  • 打赏
  • 举报
回复
'-------------------------------------------------------------------------------
'给CSDN的懒人们,这是我自己的两个宏,其实也是修改别人的,你们多在网上找找全都有了
'
'下面的宏用来给函数做注释
'注意一定要把函数头的定义全部选中,如果函数头有多行只选中一行,那么参数是不完整的
'
Sub PrintText( s, newline )
ActiveDocument.Selection = s
if newline then
ActiveDocument.Selection.NewLine
end if
end sub

Function ParseParam( s )
Trim( s )
retpos = InStrRev( s, " " )
ParseParam = Right( s, len( s ) - retpos )
end function

' this is main function
Sub CommentFunction()

Dim win
set win = ActiveWindow

if win.type <> "Text" Then
MsgBox "只有编辑窗口激活才能运行该宏."
else
fun = ActiveDocument.Selection.Text
if len(fun) = 0 then
exit sub
end if

retpos = InStr( 1, fun, " ", vbTextCompare )
retval = Left( fun, retpos - 1)
retval2 = Left( fun, retpos - 1)
lppos = InStr( 1, fun, "(", vbTextCompare )
funcname = Mid( fun , retpos, lppos - retpos )

ActiveDocument.Selection.StartOfLine
ActiveDocument.Selection.LineUp
ActiveDocument.Selection.NewLine
PrintText "////////////////////////////////////////////////////////////////////", TRUE
PrintText "// 函数: " & funcname & "()", TRUE
PrintText "// 目的: ", TRUE
author = "编程八级工"
PrintText "// 参数:", TRUE
fun = Right( fun, Len(fun) - lppos )
pos = 1

have_parameter = false
have_more = true
do while pos > 0 and have_more
pos = InStr( 1, fun, ",", vbTextCompare )
if pos = 0 then
have_more = false
pos = InStr( 1, fun, ")", vbTextCompare )
end if

if pos > 1 then
retval = Left( fun, pos - 1 )
retval = ParseParam( retval )
PrintText "// [" + retval + "] -", TRUE
have_parameter = true
end if

if have_more = true then
fun = Right( fun, Len(fun) - pos )
end if
loop
if have_parameter = true then
PrintText "// ", TRUE
else
PrintText "// -无", TRUE
end if

if retval2 = "void" then
PrintText "// 返回值:" + "[" + retval2 + "] -无", TRUE
else
PrintText "// 返回值:" + "[" + retval2 + "] -", TRUE
end if

PrintText "// ", TRUE
PrintText "// 作者: " & author & ", Created : [" & CDate(Now) & "]", TRUE
PrintText "////////////////////////////////////////////////////////////////////", FALSE
End If
end Sub
'-------------------------------------------------------------------------------
'下面的宏用来注释代码
'
'
Function FileType (ByVal doc)
ext = doc.Name
FileType = 0
pos = Instr(ext, ".")
if pos > 0 then
Do While pos <> 1
ext = Mid(ext, pos, Len(ext) - pos + 1)
pos = Instr(ext, ".")
Loop
ext = LCase(ext)
End If

If ext = ".rc" Or ext = ".rc2" Then
FileType = 7
ElseIf doc.Language = dsCPP Then
FileType = 1
ElseIf doc.Language = dsJava Then
FileType = 2
ElseIf doc.Language = dsIDL Then
FileType = 3
ElseIf doc.Language = dsVBSMacro Then
FileType = 4
ElseIf ext = ".asp" Then
FileType = 5
ElseIf doc.Language = dsHTML_IE3 Or doc.Language = dsHTML_RFC1866 Then
FileType = 6
ElseIf ext = ".def" Then
FileType = 7
Else
FileType = 0
End If

'MsgBox "Ext:" + vbTab + ext + vbLf + "Lang:" + vbTab + doc.Language + vbLf + "Type:" + vbTab + CStr(FileType)
End Function

Sub CustomCommentOut ()
'DESCRIPTION: Comments out a selected block of text.
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 = FileType(ActiveDocument)
' MsgBox "Type: " + CStr(TypeOfFile)
If TypeOfFile > 0 And TypeOfFile < 6 Then
If TypeOfFile > 3 Then
CommentType = "'" ' VBShit
CommentWidth = 1
Else
CommentType = "//" ' C++ and java style comments

CommentWidth = 2
End If

StartLine = ActiveDocument.Selection.TopLine
EndLine = ActiveDocument.Selection.BottomLine
If EndLine < StartLine Then
Temp = StartLine
StartLine = EndLine
EndLine = Temp
End If

' Single line -- comment at start of text
' have to check for comments at start of line and start of text
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

' Multi-line -- comment at start of line
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("无法注释选中的文本" + vbLf + _
"因为文件格式无法识别." + vbLf + _
"如果文件尚未保存, " + vbLf + _
"请保存后再试.")
End If
End If
End Sub
TrembleTree 2002-01-20
  • 打赏
  • 举报
回复
我用得最多的:Ctrl+Z---UNDO.:)
vioy 2002-01-20
  • 打赏
  • 举报
回复
TO:honlin

我要一份。vioy@163.net

不知道Ctrl+B加进去了没?

是调出断点列表
m_SuperIdler 2002-01-20
  • 打赏
  • 举报
回复

我用的非常多的几个键说一下吧:
shift + ctrl 切换窗口
F7编译
Ctrl + F10运行到光标处
shipatrioc 2002-01-20
  • 打赏
  • 举报
回复
关注
bfbd 2002-01-20
  • 打赏
  • 举报
回复

各位老兄,
这问题也需要讨论吗?

打开 tools->customs...->然后找到定制快捷键的选项卡,
打开 tools->customs...->然后找到定制快捷键的选项卡,
打开 tools->customs...->然后找到定制快捷键的选项卡,
打开 tools->customs...->然后找到定制快捷键的选项卡,
打开 tools->customs...->然后找到定制快捷键的选项卡,
打开 tools->customs...->然后找到定制快捷键的选项卡,
打开 tools->customs...->然后找到定制快捷键的选项卡,
打开 tools->customs...->然后找到定制快捷键的选项卡,
打开 tools->customs...->然后找到定制快捷键的选项卡,
打开 tools->customs...->然后找到定制快捷键的选项卡,
打开 tools->customs...->然后找到定制快捷键的选项卡,
打开 tools->customs...->然后找到定制快捷键的选项卡,


自己定制不是更好吗?
clickyy 2002-01-20
  • 打赏
  • 举报
回复
visual assist
非常好的add-in
加载更多回复(64)

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧