Favorite Visual Studio keyboard shortcuts

(The test code from the screenshots is only used to showcase the shortcuts and do now represent the purpose of this post.)

Toggle All Outlining: CTRL + M, CTRL + L
Collapse To Definition: CTRL + M, CTRL + O

I work sometimes with very large files containing thousands of lines of code, multiple classes and lots of regions. This is usually a bad practice and we try to improve it time and time again but it is legacy code so it can’t be changed over night. I use these shortcuts very often while browsing through such files to have a better view of the entire document. I can then go to the specific region and/or method which I need to look at further.


Navigate To: CTRL + ,

Also the projects can grow quite big and files structured in folders and subfolders are sometimes difficult to find in the Solution Explorer (Tip: use the Solution Navigator) so the Navigate To shortcut comes quite handy as it lists all the places where the search term has been found and I can go directly to the file/class/method that I was looking for.


Find In files: CTRL + Shift + F

Although the Find Usages feature is quite helpful when looking for places in the code where e.g. a method is used, with Find In Files you can search for a given term in the document, project, solution and even in specific folders.


Incremental Search: CTRL + I

This is a shortcut that I discovered recently and unlike all the other shortcuts, this searches for a specific term inside the current document without having to open a dialog.

Snippets: Tab

I also use snippets quite often and I am not sure if I can call this a shortcut but I think it’s nice when inserting a snippet (by starting to type its shortcut or by pressing CTRL + K, CTRL + X) to navigate through the editable parts by using the Tab key.


Highlighted References

This is not a shortcut but I thought I will add it to this post as a bonus because I use it so often. When you select a variable/method/… in the code, all its usages will be highlighted in the document.