[英]Shortcut for commenting CSS in VS 2008
当我在编辑CSS文件的同时按下VS2008中的标准Ctrl + E,C(其他变体)时,它说该命令不可用。 如何设置快捷方式以将简单的旧/ * * /注释应用于VS中的选定文本? 谢谢
在Visual Studio中,按Alt-F11打开宏IDE并通过右键单击MyMacros并选择添加|添加模块来添加新模块...
将以下内容粘贴到源编辑器中:
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module CommentCSS
Sub CommentCSS()
Dim selection As TextSelection
selection = DTE.ActiveDocument.Selection
Dim selectedText As String
selectedText = selection.Text
If selectedText.Length > 0 Then
selection.Text = "/*" + selectedText + "*/"
End If
End Sub
End Module
您可以通过转到“工具”|“选项...”并在左侧导航中的“ 环境”部分下选择“ 键盘”来创建键盘快捷键。 选择您的宏并指定您喜欢的任何快捷方式。
您还可以通过转到“工具”|“自定义...”并选择左侧导航中的“ 宏”部分,将宏添加到菜单或工具栏中。 在列表中找到宏后,您可以将其拖动到任何菜单或工具栏,在其中可以将文本或图标自定义为您想要的任何内容。
这是一个更简单的解决方案:
Sub CommentCSS()
DTE.ActiveDocument.Selection.StartOfLine(VsStartOfLineOptions.VsStartOfLineOptionsFirstText)
DTE.ActiveDocument.Selection.Text = "/*"
DTE.ActiveDocument.Selection.EndOfLine()
DTE.ActiveDocument.Selection.Text = "*/"
End Sub
你可以使用ctrl + shift + R自己录制
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.