Pages

Sunday, June 26, 2011

VS Shortcut Keys

No need to search Google for Visual Studio Shortcuts keys. You can get the Keyboard mappings by going to Tools –> Options –>Environment –> Keyboard.
ShortscutKeys
But there is an easy and well formatted way to get this. Some action has more than one shortcut key. Below is the Macro code for the same. Click here for details
   1:  Imports EnvDTE
   2:  Imports System.Diagnostics
   3:   
   4:  Public Module KeyboardShortcuts
   5:   
   6:      Sub ListKeyboardShortcuts()
   7:          Dim i As Integer
   8:          Dim j As Integer
   9:          Dim pane As OutputWindowPane = Utilities.GetOutputWindowPane("Commands")
  10:          Dim keys As System.Array
  11:   
  12:          pane.Clear()
  13:          pane.OutputString("<font face=arial>")
  14:          pane.OutputString("<table border=1 cellspacing=0 cellpadding=2 bgcolor=f0f0ff>" + Chr(10))
  15:          pane.OutputString("<tr><th colspan=2 bgcolor=d0d0e0>Keyboard Mappings</th></tr>" + Chr(10))
  16:          pane.OutputString("<tr><th bgcolor=e0e0f0>Action</th>")
  17:          pane.OutputString("<th bgcolor=e0e0f0>Key</th></tr>" + Chr(10))
  18:   
  19:          For i = 1 To DTE.Commands.Count
  20:              keys = DTE.Commands.Item(i).Bindings
  21:              If keys.Length > 0 Then
  22:                  pane.OutputString("<tr>")
  23:   
  24:                  'DTE.Commands.Item(i).Name() is sometimes blank.
  25:                  'We will print an m-dash in this case, as printing a blank table cell is visually
  26:                  'misleading, as such a cell has no borders, making it appear to be attached to
  27:                  'another cell.
  28:                  If DTE.Commands.Item(i).Name() <> "" Then
  29:                      pane.OutputString("<td valign=top>" + DTE.Commands.Item(i).Name())
  30:                  Else
  31:                      pane.OutputString("<td><center>&mdash;</center>")
  32:                  End If
  33:   
  34:                  pane.OutputString("</td><td>")
  35:                  For j = 0 To keys.Length - 1
  36:                      If j > 0 Then
  37:                          pane.OutputString("<br/>")
  38:                      End If
  39:                      pane.OutputString(keys(j))
  40:                  Next
  41:                  pane.OutputString("</td></tr>" + Chr(10))
  42:              End If
  43:          Next
  44:   
  45:          pane.OutputString("</table></font>")
  46:   
  47:      End Sub
  48:   
  49:  End Module


Run the Macro and copy the output and create a Html file. Below is my keyboard mapping for VS 2008: