Visual Studio Keyboard Shortcuts

In this article, I am going to share Visual Studio keyboard shortcuts and some very useful productivity tips.

Using the keyboard instead of the mouse really helps a lot to improve coding speed and Visual Studio has provided many great features with keyboard shortcuts, along with providing functions to add our own shortcuts by just following a few steps. 

 
Below are the keyboard shortcuts which I have divided into two sections - Windows Management and Editor Management.
 
Note
The "//" sign is used to add comments. 
 
Window Management
Open solution Ctrl+Shift+O //open window to navigate to the path to select a solution from drive to open
Search in Solution Explorer Ctrl+; //allow search items in the solution explorer
Add New Project Ctrl+Shift+N //open window to select new Project to add
Open Properties window F4 or Alt+Enter
Open Immediate window Ctrl+Alt+I 
Build Ctrl+Shift+B
Run F5
Restart Ctrl+Shift+F5
Add Watch Ctrl+Alt+W
Quick Watch Shift+F9 or Ctrl+Alt+Q
Rename F2 //rename any file in VS solution
Close Current item Ctrl+F4
Close All the document Ctrl+W // close all the documents which are opened; if it does not work, add own shortcut
Navigate to the previously opened file Ctrl+tab or Ctrl+Alt+ Down Arrow
Search in files Ctrl+Shift+F
Replace in files Ctrl+Shift+H
Navigate Ctrl+,
 
Editor Management
Add New File Ctrl+N
Add New Item Ctrl+Shift+A
Add Existing Item Alt+Shift+A
Save All Ctrl+Shift+S
Save current item Ctrl+S
Add class Type cl + tab tab
Add constructor Type ctro + tab tab same for other prop, if, for, intr, foreach, try etc. //very usefull to add new proerty, method, constructor, class, if else, try catch. just type 2-3 charactors and it will generate whoe syntax.  
Multi line edit / vertical typing Hold Alt+Shift and move up/down/left/right
Comment Ctrl+K+C //just select the code and press the keys
Remove comment Ctrl+K+U
Quick fix Ctrl+.
Code Snippet Ctrl+K+X and choose
Surround with Ctrl+K+S
Move line up/down Up: ALT + ↑ Down: ALT + ↓
Cut / Delete line Cut: Ctrl +L Delete: Ctrl+Shift+L //cut or delete line without selecting just place the cursor and press the keys
Collapse All C#: Ctrl+M+O
Current Method: Ctrl+M+M
Ctrl+M+A (HTML also)
Expand All Ctrl+M+L
Add/Remove Break Point F9
Delete all break point Ctrl +Shift+f9
Format code Ctrl +K+D
Got to definition F12
Go to implementation Ctrl+F12
Peek definition Alt+F12
Find reference Shift+F12
Navigate backward Ctrl + -
Navigate forward Ctrl + Shift + -

Find a complete list for all the shortcuts here: visual studio keyboard shortcut

Add shortcuts

If any shortcut does not work then a new shortcut can be defined in Visual Studio. Follow the below steps to define shortcuts.

Go to Tool > option: The following window will appear.

 
Select keyboard in the left panel then type desired function in the "show command containing" box then select the command then move cursor to “Press shortcut keys” box and press the key for a new shortcut. If that shortcut is already defined for any other function it will display below, then click ok.
 
Please see below gif.