Assigning Shortcut Keys to a Macro

by Les Smith

How do I assign a shortcut key to a Macro in Visual Studio .NET?  Once you have developed a macro, for Visual Studio NET, that you plan to use often, you may want to assign a set of shortcut keys to the macro.  This is a simple process.  First, record the macro.  Figure 1 shows a macro that I have written to duplicate a selected number of lines in a code window.

Figure 1 - Duplicate Selected Lines Macro.

    Sub DuplicateSelectedLines()
End Sub

To record the shortcut keys for this macro, go to the Tools menu and click the Options menu item.  The Options Dialog Box will open.  In the Environment folder, click Keyboard.  In the Use New Shortcut Key box, select TextEditor.  In the Commands list box, press Ctrl-Shift-/.  Finally, click the Assign and Ok Button.  Figure 2 shows the dialog after I have done these steps in the dialog.

Figure 2 - Options Dialog.