What is your favorite Visual Studio keyboard shortcut? I'm always up for leaving my hands on the keyboard and away from the mouse!
One per answer please.
What is your favorite Visual Studio keyboard shortcut? I'm always up for leaving my hands on the keyboard and away from the mouse!
One per answer please.
Ctrl+Space, Visual Studio gives the possible completions.
One that other editors should take up: Ctrl+C with nothing selected will copy the current line.
Most other editors will do nothing. After copying a line, pasting will place the line before the current one, even if you're in the middle of the line. Most other editors will start pasting from where you are, which is almost never what you want.
Duplicating a line is just: Hold Ctrl, press c, then v. (Ctrl+C, Ctrl+V)
By usage, the pair:
Haven't seen this one ...
Ctrl + Up
Ctrl + Down
Scrolls the window without moving the cursor.
One that I use often but not many other people do is:
If you type in a class name like
Collection<string>
and do not have the proper namespace import then this shortcut combination will automatically insert the import (while the carret is immediately after the '>').Update:
An equivalent shortcut from the comments on this answer (thanks asterite!):
Much more comfortable than my original recommendation.
Here is a list that I use frequently:
Ctrl + I: for progressive search. If you don't type anything after I, and keep pressing I (holding the Ctrl key down), it will search the last item you had searched. Ctrl + Shift + I will reverse search. You might also want to use F3 (and Shift + F3) once some search string is entered.
Ctrl + K Ctrl + C: For commenting highlighted region. If nothing is highlighted, current line will be commented. Naturally, you can just hold Ctrl and press K, C in succession.
Ctrl + K Ctrl + U: For uncommenting highlighted region. Works like above.
Ctrl + /: Will take the cursor to the small search box on top. You can type ">of filename" (without the quotes) to open a file. Very useful if your project contains multiple files.
Ctrl + K Ctrl + K: Will bookmark the current line. This is useful if you want to look at some other part of code for a moment and come back to where you were.
Ctrl + K Ctrl + N: Will take you to the next bookmark, if there are more than one.
Ctrl + -: Will take the cursor to its previous location
Ctrl + Shift + -: Will take the cursor to its next location (if it exists)
Ctrl + Shift + B: Build your project
Ctrl + C: Although this does the usual copy, if nothing is highlighted, it copies the current line. Same for Ctrl + X (for cut)
Ctrl + Space: Autocomplete using IntelliSense
Ctrl + ]: Will take you to the matching brace. Works with all kinds of braces: '(', '{', '['. Useful for big blocks.
F12: Will take you to the function definition/variable definition.
Alt + P + P: Will open up project properties. Although not many use this, it useful if you want to quickly change the command line arguments to your program.
F5: To start debugging
Shift + F5: To stop debugging
While debugging, you can use Ctrl + Alt + Q to add a quick watch. Other debugging shortcuts can be found in the debug drop down menu.