[Tip: Visual Studio]创建键盘快捷方式速查表

本文介绍了一个用于生成Visual Studio键盘快捷方式列表的宏。通过此宏,可以创建一个HTML文件,详细列出所有默认快捷方式及其对应的功能,便于开发人员快速查找并学习。

创建键盘快捷方式速查表。

大部分开发人员都不了解这一点,但实际上,Visual Studio 默认提供了 450 多个键盘快捷方式。不过,对于如何找到 Visual Studio 内部的所有键盘快捷方式还没有简便的方法。您可以编写一个简单的宏,对于所有默认键盘快捷方式进行遍历,找到它们所对应的操作。以下内容(列表 1)列出了这个宏的代码。

Public Module Module1
      Public Sub ListShortcutsInHTML()
          'Declare a StreamWriter
        Dim sw As System.IO.StreamWriter
        sw = New System.IO.StreamWriter("c:\\Shortcuts.html", True, System.Text.Encoding.GetEncoding("SHIFT-JIS"))
          'Write the beginning HTML
        WriteHTMLStart(sw)
          ' Add a row for each keyboard shortcut
        For Each c As EnvDTE.Command In DTE.Commands
            If c.Name <> "" Then
                Dim bindings As System.Array
                bindings = CType(c.Bindings, System.Array)
                For i As Integer = 0 To bindings.Length - 1
                    sw.WriteLine("<tr>")
                    sw.WriteLine("<td>" + c.Name + "</td>")
                    sw.WriteLine("<td>" + bindings(i) + "</td>")
                    sw.WriteLine("</tr>")
                Next
              End If
        Next
          'Write the end HTML
        WriteHTMLEnd(sw)
          'Flush and close the stream
        sw.Flush()
        sw.Close()
    End Sub
    Public Sub WriteHTMLStart(ByVal sw As System.IO.StreamWriter)
        sw.WriteLine("<html>")
        sw.WriteLine("<head>")
        sw.WriteLine("<title>")
          sw.WriteLine("Visual Studio Keyboard Shortcuts")
        sw.WriteLine("</title>")
        sw.WriteLine("</head>")
          sw.WriteLine("<body>")
        sw.WriteLine("<h1>Visual Studio 2005 Keyboard Shortcuts</h1>")
        sw.WriteLine("<font size=""2"" face=""Verdana"">")
        sw.WriteLine("<table border=""1"">")
        sw.WriteLine("<tr BGCOLOR=""#018FFF""><td align=""center""><b>Command</b></td><td align=""center""><b>Shortcut</b></td></tr>")
      End Sub
      Public Sub WriteHTMLEnd(ByVal sw As System.IO.StreamWriter)
        sw.WriteLine("</table>")
        sw.WriteLine("</font>")
        sw.WriteLine("</body>")
        sw.WriteLine("</html>")
    End Sub
End Module
 

列表 1. 在 HTML 文件中生成键盘快捷方式的宏

要使用这个宏,请转到“工具”,选择“宏”,然后选择“宏 IDE. . .”启动“宏 IDE”。展开 MyMacros 工程,MyMacros 命名空间,然后双击“Module1”。将列表 1 中的内容复制到“宏 IDE”然后运行宏即可。运行宏之后,将会生成 Visual Studio 的键盘快捷方式参考信息。打开包含输出内容的 C:\demo\Shortcuts.html 文件。“图 1”显示了部分输出内容。如果方便就将它打印出来,贴在计算机附近,以便学习新的键盘快捷方式。

转载于:https://www.cnblogs.com/taoxu0903/archive/2010/02/09/1666728.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值