The Visual Studio shell is a big place. I should know, since I used Visual J++ everyday for a year before joining the team. As I write these tips, I try to think back to my J++ days to come up with a list of tips and tricks I wish I had known back then and what I now take for granted. One of these is definitely keyboard binding. Maybe I didn’t look hard enough for features within Visual Studio. Maybe I never needed to rebind a command, so I never discovered this. Anyways, here’s how to do it, so now everyone knows.
To create or change a keyboard shortcut for a given command:
If there’s a conflict, the Shortcut currently used by: will show the conflict. Press Assign to override the conflict.
Note that there are different scopes. The Use new shortcut in: combo box show the current scope for that particular keyboard shortcut with the Global scope as the default. For example, keyboard shortcuts assigned in the Text Editor scope will only work when focus is in the text editor (same as code editor). If you place focus on a tool window and try the same keyboard shortcut, the command that is bound to that keyboard shortcut under global scope will execute.
To find out what command a keyboard shortcut is bound to:
Another “fun” way of learning about Visual Studio is to scroll through the list of commands available. For example, if you type Edit.Line, you’ll see all of the commands that contain “Edit.Line”. You’ll discover a command called “Edit.LineTranspose” which is bound to Shift+Alt+T. In case you ever need to transpose a line, you now know the keyboard shortcut for it. =)
Technorati tags: VS2005Tip, VS2008Tip