There are hundreds of keyboard shortcuts in Visual Studio, but you don’t need to memorize them all to increase your proficiency. Take a moment to think about how you use Visual Studio every day. I’ll bet there are actions that you perform dozens of times a day. And chances are, to paraphrase from Apple, “there is a shortcut for that”.
So, what is wrong with using a mouse? Nothing. Absolutely nothing at all. Just like it would be very difficult (and foolish) to develop software without a keyboard, the same can be said about not using a mouse. But that doesn’t mean shortcuts are not useful. Just in writing these few paragraphs I’ve used Ctrl + S (Save), Ctrl + Z (Undo), Ctrl + Y (Redo) more than a dozen times.
I could have taken my hand off the keyboard, reached for the mouse, looked for the buttons on the toolbar, clicked on the button, moved my hand back to the keyboard and continued typing. Sound like a lot of work? I know it isn’t as bad as it sounds, but why would I go through the trouble when it is so convenient and quick to use a shortcut? Hopefully you agree that shortcuts can be useful and save you time, so without further ado...
Basic Shortcuts
You probably know these already if you use any type of text editor, but just to be thorough ...
|
Cut |
Ctrl + X |
|
Copy |
Ctrl + C |
|
Paste |
Ctrl + V |
|
Undo |
Ctrl + Z |
|
Redo |
Ctrl + Y |
|
Save |
Ctrl + S |
|
Save All |
Ctrl + Shift + S |
Editing
|
Show Smart Tag |
Ctrl + Dot (.) |
Probably my favorite shortcut. Anytime you see the smart tag tip, you can use this shortcut to expand the menu. Rename a variable, implement an interface, etc... Ctrl + Dot (.), then Enter and BAM, done. |
|
Insert Snippet |
Ctrl + K, X |
Another of my favorites. I suggest getting familiar with the dozens of snippets available, they can be a real time saver. |
|
Comment Code |
Ctrl + K, C |
|
|
Uncomment Code |
Ctrl + K, U |
|
|
Replace |
Ctrl + H |
|
Text Navigation
Incremental Search Forward and Backward |
Ctrl + I & Ctrl + Shift + I |
A faster way to find text in the current window. Just hit Ctrl + I, then start typing away and VS will find the text you entered. Hit Ctrl + I again and it will find the next match. |
|
Go to Brace |
Ctrl + ] |
This one is great. Do you have too many braces and want to know where the matching brace is? Then this shortcut is for you. |
|
Find |
Ctrl + F |
|
|
Go To Reference |
F12 |
This shortcut in combination with Navigate Backward / Forward can be a real time saver. |
|
Navigate Backward and Forward |
Ctrl + Hyphen (-) & Ctrl + Shift + Hyphen (-) |
Moves to the previously browsed line of code. |
|
Go to document Start and End |
Ctrl + Home & Ctrl + End |
|
Debugging
|
Build Solution |
Ctrl + Shift + B |
Probably the shortcut I use the most in a day. Want to know if the code you just wrote compiles? Ctrl + Shift + B is your friend then. |
|
Debug |
F5 |
|
|
Stop Debug |
Shift + F5 |
|
|
Toggle Breakpoint |
F9 |
|
|
Step Into |
F11 |
|
|
Step Out |
Shift + F11 |
|
|
Step Over |
F10 |
|
|
Attach To Process |
Ctrl + Alt + P |
This one is great with web applications. Instead of stopping, changing code, restarting and navigating back to the location.Just keep the browser open and attach to the w3wp.exe process (IIS7) or iisexpress.exe (IIS Express).
May need to have Show processes in all sessions checked to find the process. |
Window Navigation
|
Cycle Window Backward and Forward |
Ctrl + Tab & Ctrl + Shift + Tab |
|
|
Close Window |
Ctrl + F4 |
|
|
Show Output Window |
Ctrl + Alt + O |
|
|
Go to Solution Explorer |
Ctrl + Alt + L |
This shortcut is great for navigating between files in your solution. Ctrl + Alt + L will open/set your focus in Solution Explorer from where you can navigate to other files (of course by using up/down keys) |
|
View Error List |
Ctrl + W, E |
|
File Manipulation
|
New File |
Ctrl + N |
|
Rename |
F2 |
You can also create your own shortcuts very easily. Just navigate to Tools > Options > Keyboard. One of my favorite commands that is not mapped is Remove and Sort which I map to Ctrl + R, S.
There you go, about two dozen shortcuts that can make you a lot more productive in Visual Studio. Once you have mastered the basic shortcuts, start learning the more meaty ones. Take your time and learn one or two shortcuts a day. Soon you won’t be as dependent on your mouse and will be more productive. Now you can practice your mouse dexterity in say, Angry Birds for the PC with your newly found spare time.
Resources
Visual Studio Key Commands Chart (PDF)
Visual Studio 2010 Keybinding Posters