[Tip: Visual Studio] Create a keyboard shortcut quick query table

Source: Internet
Author: User

Create a keyboard shortcut quick query table.

Most developers do not understand this, but Visual Studio provides over 450 keyboard shortcuts by default. However, there is no easy way to find all keyboard shortcuts in Visual Studio. You can write a simple macro to traverse all the default keyboard shortcuts and find their corresponding operations. The code for this macro is listed below (List 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("        sw.WriteLine("        sw.WriteLine("<title>")
          sw.WriteLine("Visual Studio Keyboard Shortcuts")
        sw.WriteLine("</title>")
        sw.WriteLine("
          sw.WriteLine("<body>")
        sw.WriteLine("        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("    End Sub
End Module
 

List 1. Generate a keyboard shortcut macro in the HTML file

To use this macro, go to "tool", select "macro", and select "macro ide..." to start "macro ide ". Expand the mymacros project, name the mymacros, and double-click module1 ". Copy the content in List 1 to "macro ide" and then run the macro. After running the macro, the keyboard shortcut reference information of Visual Studio is generated. Open the c: \ demo \ shortcuts.html file containing the output content. Figure 1 shows some output content. Print it out and paste it near your computer to learn new keyboard shortcuts.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.