Visual Studio .NET Keyboard Shortcuts Macro
Tuesday, August 2, 2005
By: Jason Doucette

This article describes how to create and run a macro, from within Visual Studio .NET, which produces an HTML table showing all of your current keyboard mappings (shortcuts).  It is useful for finding key bindings, and provide a much easier way to merely browse through them, rather than using Visual Studio's ridiculously small browse window (which shows 4 and a half  listings at once).


How to Create the Macro

To create this macro, go into Tools menu -> Macros -> Macros IDE...

Within Project Explorer, right-click MyMacros, select Add, select Add Module...

Add a new module named 'KeyboardShortcuts'.

Copy the entire macro source (listed at the bottom of this article), and paste it into the new module.  You will notice the 'Utilities' line within the source code is underlined in blue, indicating an error.

To rectify this, go into the 'Samples' directory inside Project Explorer, and find the 'Utilities' module.  You need to copy this entire 'Utilities' module from the 'Samples' directory into the 'MyMacros' directory, using standard copy and paste operations.  If you do not make a copy of the 'Utilities' module in the 'MyMacros' directory, the code will not be able to reference it.

Build the macro by clicking Debug menu -> Build.  If there are no errors - which is indicated by a lack of any response whatsoever from the IDE <sigh> - then everything is ready.  (If there is an error, the Macro IDE will highlight it, and show the error in the Task List window.)  You can now close the Macro IDE window, as the macro will be run from the main Visual Studio window.


How to Run the Macro

Go to Tools menu -> Macros -> Macro Explorer.

Under 'MyMacros', under the 'KeyboardShortcuts' directory, a new macro called 'ListKeyboardShortcuts' will be available.

To run the macro, double click it.  If you wish to see the macro's progress as it runs, make sure the Output window is open before you start it.  The macro will take approximately 30 seconds to run.  Once it is complete, copy the entire text of the Output window, and paste it into an HTML file.  Sample macro output is shown within the pages linked below.


Macro Source

Imports EnvDTE Imports System.Diagnostics Public Module KeyboardShortcuts Sub ListKeyboardShortcuts() Dim i As Integer Dim j As Integer Dim pane As OutputWindowPane = Utilities.GetOutputWindowPane("Commands") Dim keys As System.Array pane.Clear() pane.OutputString("<font face=arial>") pane.OutputString("<table border=1 cellspacing=0 cellpadding=2 bgcolor=f0f0ff>" + Chr(10)) pane.OutputString("<tr><th colspan=2 bgcolor=d0d0e0>Keyboard Mappings</th></tr>" + Chr(10)) pane.OutputString("<tr><th bgcolor=e0e0f0>Action</th>") pane.OutputString("<th bgcolor=e0e0f0>Key</th></tr>" + Chr(10)) For i = 1 To DTE.Commands.Count keys = DTE.Commands.Item(i).Bindings If keys.Length > 0 Then pane.OutputString("<tr>") 'DTE.Commands.Item(i).Name() is sometimes blank. 'We will print an m-dash in this case, as printing a blank table cell is visually 'misleading, as such a cell has no borders, making it appear to be attached to 'another cell. If DTE.Commands.Item(i).Name() <> "" Then pane.OutputString("<td valign=top>" + DTE.Commands.Item(i).Name()) Else pane.OutputString("<td><center>&mdash;</center>") End If pane.OutputString("</td><td>") For j = 0 To keys.Length - 1 If j > 0 Then pane.OutputString("<br/>") End If pane.OutputString(keys(j)) Next pane.OutputString("</td></tr>" + Chr(10)) End If Next pane.OutputString("</table></font>") End Sub End Module



The macro originated from a 'Lance' on the Visual Studio Core Team. William Garrison found this macro on the microsoft.public.vsnet.ide newsgroup, and modified it to improve its output. I found his modifications on William's website and further modified it to clear the confusion of blank cells.


Sample Macro Output

I have run the macro from within Visual C++ .NET 2003 (v7.1), with the Keyboard Mapping Scheme set to emulate all of the possible pre-set settings. You can set it yourself by going to: Tools menu -> Options -> Environment -> Keyboard -> Keyboard Mapping Scheme. I should note that while these Keyboard Mapping Scheme settings are supposed to exactly replicate the keyboard mappings of different versions of Visual Studio, it is known to be somewhat inaccurate. I recall only one such incident, and there may be more: One of the mapping schemes did not provide a particular shortcut that an author was accustomed to. Searching the above macro's output proved that the shortcut was not only missing, but did not exist at all.

Here are the five Keyboard Mapping Schemes that come with Visual C++ .NET 2003 (v7.1):





About the Author: I am Jason Doucette of Xona Games, an award-winning indie game studio that I founded with my twin brother. We make intensified arcade-style retro games. Our business, our games, our technology, and we as competitive gamers have won prestigious awards and received worldwide press. Our business has won $180,000 in contests. Our games have ranked from #1 in Canada to #1 in Japan, have become #1 best sellers in multiple countries, have won game contests, and have held 3 of the top 5 rated spots in Japan of all Xbox LIVE indie games. Our game engines have been awarded for technical excellence. And we, the developers, have placed #1 in competitive gaming competitions -- relating to the games we make. Read about our story, our awards, our games, and view our blog.

Home | Games | Awards | About | Learn | Blog | Press Kit | Contact

Xona Games,, Xonatech, Saw Tooth Distortion, Evolutionary Prototype (EP), Duality ZF, Decimation X, Decimation X2,
Decimation X3, Decimation X3.5, Decimation X4, Score Rush, Score Rush 2, Score Rush (HTML5), Score Rush MP, and Score Rush Extended (Score Rush EX)
trademarked and copyrighted by Xona Games Inc., Matthew Doucette, and/or Jason Doucette.
© 2000..2005 Saw Tooth Distortion. © © 2008..2010 Xona Games (under
© Xona Games Inc.

We make Intense Retro video games.