.NET Power Tip 14: Navigation in Visual Studio


This power tip introduces a couple of shortcuts that can be used to navigate through code files in Visual Studio. I am often surprised about how many developers don’t know or don’t use some of the most basic shortcuts. Note that the mentioned key bindings can be different in your edition of Visual Studio. So here we go:


Since VS2010, the command NAVIGATE-TO is included in Visual Studio. Using CTRL-COMMA (depending on the region settings) you can open a search window. Visual Studio will search for the text entered in Files, Classes and Symbols. Symbols summarizes everything that has been created in code, such as properties, fields, events, enums and son on. When you select a find result and hit enter, Visual Studio jumps to the corresponding code in the code editor.


Navigate Backward/Navigate Forward

Often, reading code is more like jumping through one code file after the other. It is very easy to lose track when you are following a method call hierarchy and changing from one file to another. Many times it is useful to jump back to the place in the last file. NAVIGATE BACKWARD (CTRL + -) and NAVIGATE FORWARD (CTRL + SHIFT + –) do exactly that. The commands are available via keyboard shortcuts or buttons in the tool bar.


GoTo Definition, Peek Definition and GoTo Implementation

You might already know that you can use GO TO DEFINITION (F12) to jump to the definition of an element, such as a method or a class, at the location of the cursor. Using the PEEK DEFINITON (ALT – F12) command, you can look at the definition without leaving the current code file and losing the context. The definition is shown in a Popup window. Using SHIFT – ESC it is possible to switch between the Peek Window and the outer code Window. You can then either close the Peek Window using the ESC key or propagate it to a normal window using the CTRL-ALT-HOME shortcut. The following image shows the Peek Definition Window:


If your instance of Visual Studio has the Productivity Power Tools (see: http://www.manuelmeyer.net/2016/02/net-power-tip-11-visual-studio-productivity-power-tools/) installed, there is a now PEEK command available. Holding the CTRL key while clicking an element in code will open the Peek Definition Window as well.

The problem with the GOTO DEFINITION command is that when you are programming against interfaces, you will jump to the interface definition and not the implementation of the method. Fortunately, the update 1 for Visual Studio 2015 includes a new command called GO TO IMPLEMENTATION.

OpenLiveWriter (OLW) Cannot Detect WordPress Theme
.NET Power Tip 15: The Call Hierachy Window in Visual Studio

0 Comment


This site uses Akismet to reduce spam. Learn how your comment data is processed.

15 49.0138 8.38624 1 0 4000 1 https://www.manuelmeyer.net 300 0