Freigeben über


Create a Shortcut Key for a Macro

Menu:  Tools -> Options -> Keyboard
Command:  Tools.CustomizeKeyboard
Versions:  2008,2010
Published:  8/7/2010
Code:  vstipTool0066

 

We covered creating shortcuts in vstipTool0063.  Assuming you have a macro you would like to attach a shortcut key to, you can easily make your macros accessible.  Let's do an example to show you how.  First, go to Tools -> Options -> Keyboard :

image

 

To access your macros type "macro." in the "Show commands containing" area:

image

 

In this case let's bind the "Macros.Samples.Utilities.TurnOffLineNumbers" and "Macros.Samples.Utilities.TurnOnLineNumbers" macros:

WARNING:   You will want to make sure the keyboard shortcuts I use here aren't already assigned to something else.  They most likely aren't but you should double-check.

image

 

For "Macros.Samples.Utilities.TurnOnLineNumbers" we will bind it to CTRL + M, CTRL + 1:

image

 

For "Macros.Samples.Utilities.TurnOffLineNumbers" we will bind it to CTRL + M, CTRL + 0:

image

 

Click the OK button and let's test out our shortcuts.  Go to any source code:

image

 

As you can see, I have line numbers on already so I'll press CTRL + M, CTRL + 0 to turn them off and CTRL + M, CTRL + 1 to turn them back on again.