While working with Visual Studio, you may some time notice that, there are few Visual Studio commands which are not mapped with any keyboard shortcuts. Thus, working with such commands become very difficult as you need to navigate through the menus every time.
Do you know that, you can easily map custom shortcut keys to Visual Studio commands to ease your life? In this part of my Visual Studio Productivity Tips series, we will learn about the steps.
Visual Studio Productivity Tips:
In our previous Tips & Tricks about Visual Studio, we learnt how easy it is to navigate from one method to another by using the Visual Studio menu Edit | Next Method and Edit | Previous Method. Wouldn't it be more easy if we had a keyboard shortcut mapped to the functions to perform the said navigation?
Yes, it is! Here we will talk about the step-by-step process to map a Visual Studio command with custom keyboard shortcuts.
Let's take the previous post as the example. We had the following commands: Next Method and Previous Method, where no keyboard shortcuts have been assigned. Check the below screenshot for reference:
Now, to assign keyboard shortcut keys for the mentioned Visual Studio menu commands, navigate to the Visual Studio Options page by clicking Tools | Options... menu items.
Now, navigate to Environment | Keyboard, as shown in the below screenshot and then search for the command containing the text nextmethod. This will filter out the result and list Edit.NextMethod as shown below.
Click on the input box under the Press shortcut keys and press the keyboard new key combination that you want to assign against the command. In this example, we have assigned Ctrl + Shift + = as the shortcut key. Click the Assign button.
Similarly, to assign keyboard shortcut for the other command, search for previousmethod. This will filter out the result and list Edit.PreviousMethod as shown below.
Now, click on the input box under the Press shortcut keys and press the keyboard new key combination that you want to assign against the command. In this example, we have assigned Ctrl + Shift + Alt + = as the shortcut key. Click the Assign button and hit OK to save the changes to Global settings.
Navigate to Edit menu now. You will see that the assigned keyboard shortcuts against the Next Method and Previous Method menu items have been set to Ctrl + Shift + = and Ctrl + Shift + Alt + = respectively, as shown in the below screenshot:
Similarly, when you find another Visual Studio command, for which no keyboard shortcut has been assigned by Microsoft, you can now easily add your custom keyboard shortcut to it.
Make sure that, you are not overriding any existing mapping. Also make sure that you are saving the changes in the Global settings, so that, the changes are available in your system for all new instances of Visual Studio.