Welcome to the next in the series of posts on program shortcuts. This time round we’re talking Visual Studio. I’ll be assuming that you don’t have the ViEmu plugin enabled and that you’re just using the IDE in the way it was intended without any other form of shortcut-based plugin installed.
I’m using Visual Studio 2005 and I think I have the C# settings enabled by default. Most of these shortcuts will work regardless of the default setting that you have, but some of them will no doubt be different. Please note that I won’t be going through every single shortcut that Visual Studio supports, instead I’ll be going through the ones that I find very handy. If you’re looking to find a complete list, then you should check out MSDN.
Basic text manipulation shortcuts are the same as what is posted in the Windows shortcuts entry that I posted. OK, on with the goodies.
- CTRL + Space or CTRL + K, L - Display the Intellisense members drop-down based on the current cursor position, or auto-complete the current symbol.
- CTRL + SHIFT + Space or CTRL + K, P - Display the Intellisense parameter list tool-tip based on the corrent curosr position (handy for when you’ve forgotten a function’s singature).
- CTRL + F3 - Find the next instance of the word under the cursor.
- F3 - Find the next instance of the search word.
- SHIFT + F3 - Find the previous instance of the search word.
- F5 - Run in the debugger.
- SHIFT + F5 - Run without the debugger.
- F6 - Build solution.
- SHIFT + F6 - Build current project.
- F7 - Show code for the current item.
- CTRL + F7 - Compile current file.
- F9 - Toggle breakpoint.
- F10 - Step over current line (while debugging).
- F11 - Step into the current function call (while debugging).
- F12 - Go to definition.
- CTRL + SHIFT + B - Rebuild.
- CTRL + SHIFT + F9 - Remove all breakpoints.
- CTRL + D, B - Show the breakpoints window.
- CTRL + D, E - Show the exceptions window.
- CTRL + D, N - Set breakpoint in a function call.
- CTRL + D, I - Show the Immediate window.
- CTRL + ALT + P - Attach the debugger to a currently running process.
- CTRL + SHIFT + A - Add a new item to the project.
- SHIFT + ALT + A - Add an existing item to the project.
- SHIFT + ALT + C - Add a new class to the project.
- CTRL + - - Navigate to previous location. If you’ve gone to the definition of a function, or moved to the end of a file, this shortcut will take you back to where you were. Quite handy for when you need to do things like add #includes to the top of the file and then return to where you were before.
- CTRL + SHIFT + - - Same as the previous shortcut, but navigating forward again.
- CTRL + F - Open the Quick Find dialog.
- CTRL + SHIFT + F - Open the Find in Files dialog.
- CTRL + H - Open the Replace dialog.
- CTRL + SHIFT + H - Open the Replace in Files dialog.
- ALT + F12 - Open the Find Symbol dialog.
- CTRL + SHIFT + V - Cycle through the clipboard ring.
- CTRL + K, F - Auto-format current selection.
- CTRL + K, D - Auto-format current document.
- CTRL + K, S - Surround selection with a template/code snippet.
- SHIFT + ALT + Enter - Toggle Fullscreen.
- CTRL + K, K or CTRL + B, T - Toggle bookmark at the current location.
- CTRL + K, N or CTRL + B, N - Move to the next bookmark.
- CTRL + B, P - Move to the previous bookmark.
- CTRL + B, C - Clear all bookmarks.
- CTRL + K, C - Comment out selected text.
- CTRL + K, U - Uncomment selected text.
- CTRL + M, M - Toggle view of current fold.
- CTRL + M, L - Toggle view of all folds.
- CTRL + M, O - Collapse to definitions.
- CTRL + M, H - Hide selected text (shows up as ‘…’).
- CTRL + M, U - Unhide selected text.
It’s far from an exhaustive list, but I think there may well be some in there that you haven’t seen before. There are a stack more, so check out the documentation if this little list doesn’t sort you out.











February 12, 2007
I didn’t see CTRL + K,D in there which you probably know is to auto-format the whole file. I couldn’t be bothered to select a piece of code and hit CTRL + K,F, I just nail the whole file each time.
Another shortcut I use particularly often is CTRL + K,S which “surrounds” selected code with any particular code snippet you choose. I often do this with if, select, foreach and for’s if I decide a particular piece of code needs to be inside one of those blocks. For me, this beats creating the construct you want above the code, and then adding the braces yourself, because it also activates the snippet for you to help fill in the blanks. Give it a go, you’ll see what I mean.
February 12, 2007
Neato! Yup, forgot to add CTRL + K, D (it’s in there now), and didn’t know about CTRL + K, S so i’ll shove that in there too!
Cheers Rob.
February 12, 2007
Good one, Ollie…
I have also use Shift+Alt+F10: which is handy when you are writing code. When your cursor is positioned on any declarations (method, properties) and the type namespace is not included or the method is not declared, it will give you the option to either implicitly declare it, or add a “using” statement at the top.
Another case is when you declare interface on the class declaration, you can add the using and implement the interface on your class using this short cut.
Y.
February 13, 2007
Very nice - definitely a few there I didn’t know, though I have Visual Studio set up to old skool F7 to build rather than CTRL-SHIFT-B, which is total overkill in my opinion.
Also, if you have Visual Assist installed, SHIFT-ALT-O (open file in solution) is another invaluable shortcut, though perhaps that’s going slightly off topic…
February 13, 2007
Yoann: I didn’t know about that one. Doesn’t seem to work with C++ (both managed and unmanaged). Is is specific to VB.NET or C#?
Keef: Slightly O.T., but I’ll let it slip
Visual Assist X is a very nice piece of kit.
February 27, 2007
Something i’ve just come across which may be useful but isn’t a keyboard shortcut (although it could still be classed as a shortcut): If you need to see the value of a string variable but it’s too long to fit in the tooltip for that variable or the locals/autos/watch window then you can bring up the Command Window and type ‘Debug.Print ‘ followed by the variable name and you’ll get a nice print out of the variable. Also works for variables that aren’t strings and can access members of classes as well.
I’ve also tried this in VS 2003 but I imagine it will exist in some form in 2005.
September 23, 2007
I recently hit some key combination to display the page formatting in VS 2005. When programming in C++ I now have an arrow for every tab and period for every space. The problem? I have no idea what key combination/command removes the arrows and periods, any suggestions?
September 23, 2007
For those interested, the key combination is ctrl + r, ctrl + w for show/hide whitespace (Also located in Edit>Advanced menu). Very annoying when viewable.
September 23, 2007
Damn, didn’t see both of these comments until this morning. You beat me to it. Thanks for posting again with the answer
September 25, 2007
Ctrl-Alt-V Reshow the Auto match window.
September 10, 2008
By clicking on F6 i am not able to build the solution please tell me how can i set these settings?
September 12, 2008
@sivaram: You need to rebind your F6 key to the appropriate command. Here are the instructions:
Good luck!
October 11, 2008
ctrl + } while cursor is next to a parenthesis or brace takes you to the it’s partner. useful for jumping back in forth in large functions where you can’t easily see what the closing brace goes to.