[Tip: Visual Studio]建立鍵盤快速鍵速查表

來源:互聯網
上載者:User

建立鍵盤快速鍵速查表。

大部分開發人員都不瞭解這一點,但實際上,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”顯示了部分輸出內容。如果方便就將它列印出來,貼在電腦附近,以便學習新的鍵盤快速鍵。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.