创建 Visual Studio 快捷键

发布于 2024-08-09 11:10:00 字数 101 浏览 3 评论 0原文

我在新项目中做了很多事情,例如,输入对 Google AJAX API 的简单调用以包含 jQuery。我可以以某种方式在 VS 中映射我自己的快捷方式组合,让它在我输入快捷方式时插入吗?

There are some things that I do a lot in a new project, for example, entering in a simple call to the Google AJAX API to include jQuery. Can I somehow map my own shortcut combo in VS to have it insert this is when I enter my shortcut?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

邮友 2024-08-16 11:10:00

1)您必须创建一个宏,将当前文本插入光标所在的位置。例如,要为突出显示的文本插入时间戳(如 Migratordotnet),我在 MyMacros 项目中有此宏:

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Imports System.Security.Principal

Public Module Tools
    Public Sub DateTimeStamp()
        Dim textSelection As EnvDTE.TextSelection
        textSelection = DTE.ActiveDocument.Selection
        textSelection.Insert(String.Format("{0:yyyyMMddHHmmss}", DateTime.Now))
    End Sub
End Module

2) 转到“工具”->“选项->环境/键盘 ->在“显示包含以下内容的命令”选项中突出显示您的宏 ->在“按快捷键”框中输入要与宏关联的组合键/和弦。至于“使用新的快捷方式:”部分,全局选项将应用于 Visual Studio 中的每个文档类型,无论焦点在哪里。因此,对于上面的示例,可以在 Macros.MyMacros.Tools.DateTimeStamp 中找到该命令。

1) You would have to create a Macro that inserts the current text where the cursor is. For example, to insert a timestamp for the highlighted text (like for Migratordotnet) I have this macro in the MyMacros project:

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Imports System.Security.Principal

Public Module Tools
    Public Sub DateTimeStamp()
        Dim textSelection As EnvDTE.TextSelection
        textSelection = DTE.ActiveDocument.Selection
        textSelection.Insert(String.Format("{0:yyyyMMddHHmmss}", DateTime.Now))
    End Sub
End Module

2) Go to Tools -> Options -> Environment/Keyboard -> Highlight your Macro in the "Show commands containing:" selection -> in the "Press shortcut keys" box do the key combination/chord you want to associate to the macro. As for the "Use new shorcut in:" section, the Global option will apply to every document type in Visual Studio, no matter where the focus is. So for my example above, the command is found at Macros.MyMacros.Tools.DateTimeStamp.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文