在VS 2008中注释CSS的快捷方式 [英] Shortcut for commenting CSS in VS 2008

查看:321
本文介绍了在VS 2008中注释CSS的快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在编辑CSS文件时按下VS2008中的标准Ctrl + E,C(其他变体),它说该命令不可用。如何设置一个快捷方式来应用一个简单的老/ * * /评论在VS中选定的文本?感谢

解决方案

在Visual Studio中,按Alt-F11打开宏IDE并通过右键单击MyMacros并选择添加|添加模块...



在源代码编辑器中粘贴以下内容:

 导入系统
导入EnvDTE
导入EnvDTE80
导入EnvDTE90
导入System.Diagnostics

公共模块注释CSS
Sub CommentCSS()
Dim selection As TextSelection
selection = DTE.ActiveDocument.Selection

Dim selectedText As String
selectedText = selection.Text

如果selectedText.Length> 0 then
selection.Text =/ *+ selectedText +* /
结束如果
结束子
结束模块



您可以通过以下方式创建键盘快捷方式:转到工具|选项...,然后选择环境部分。选择您的宏并分配您喜欢的任何快捷方式。



您也可以通过转到工具|自定义...并选择导航栏中的部分,将宏添加到菜单或工具栏在左边。在列表中找到宏后,您可以将其拖动到任何菜单或工具栏,其中文本或图标可根据您的需要自定义。


When I press the standard Ctrl + E, C (an other variants) in VS2008 whilst editing a CSS file, it says that command is not available. How do I setup a shortcut to apply a plain old /* */ comment to selected text in VS? Thanks

解决方案

Within Visual Studio, hit Alt-F11 to open the Macro IDE and add a new module by right-clicking on MyMacros and selecting Add|Add Module...

Paste the following in the source editor:

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

You can create a keyboard shortcut by going to Tools|Options... and selecting Keyboard under the Environment section in the navigation on the left. Select your macro and assign any shortcut you like.

You can also add your macro to a menu or toolbar by going to Tools|Customize... and selecting the Macros section in the navigation on the left. Once you locate your macro in the list, you can drag it to any menu or toolbar, where it its text or icon can be customized to whatever you want.

这篇关于在VS 2008中注释CSS的快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆