Editor's Note: The following post was written by Visual Basic MVP Deborah Kurata
Visual Studio 2013 Navigate To Improvements
The Navigate To (or Ctrl+Comma) feature provides search-as-you-type support for code files, full file paths, and symbol names such as class names and member names. This feature was new in Visual Studio 2010, unchanged in Visual Studio 2012, and improved significantly in 2013.
Navigate To in VS 2010/2012
We’ll look at Navigate To first in Visual Studio 2012. You can find this feature under the Edit menu or use Ctrl+Comma. Navigate To displays a modal dialog (see Figure 1).
In the Search Terms box in the dialog, you can enter any text to search. As you type, the matches are displayed in the Results list. This feature finds the text anywhere in the path name, code file name, type name, or type member names. Select the result you want and click OK to navigate to the selected item.
This is different from the find feature in that it only matches on the path, file and symbol names, not any other text in your code.
For example, if I type “invoice”, it will find a match in the Invoice property names, Invoice class, and Invoice code file as shown below.
Figure 1. Navigate To in Visual Studio 2010/2012.
Say good-bye to this modal dialog.
Navigate To in VS 2013
The Navigate To feature is still available in Visual Studio 2013 from the Edit menu or by using Ctrl+Comma. But now it appears “in document” similar to the current Find feature. I've added an arrow in Figure 2 pointing to the Navigate To search box.
Figure 2. Navigate To in Visual Studio 2013.
If I again type "invoice", it presents the same list. Only now the results are not confined to a modal dialog.
Figure 3. Navigate To Search Results.
The first result is automatically selected. The selected result immediately appears in the Preview Tab. You can see in Figure 3 that the Invoice class was found, selected, and displayed in the Preview tab to the right on the tab bar.
You can preview each result by navigating through the list. Use the up and down arrow keys or the mouse. Each selected result appears in the preview tab. This allows you to preview the result to determine whether you really want to navigate without committing to it.
I can’t tell you how many times I have used Navigate To in prior versions of Visual Studio and end up in the wrong place. And with the modal dialog, I had to start all over with my search. So it is nice to see where you will go before going there.
When you find the result you want, select it and press the Enter key, or double-click it with the mouse.
Press ESC at any time to close the Navigate To and return to your code.
NOTE: Visual Studio does not provide a preview of designer files. So when you select a designer file in the result list, the Preview tab continues to display the last previewed file.
The Navigate To search box supports much more than simple search strings.
You can use white space between sets of characters. The white space is treated as an "and". For example: "inv am" displays only the results that contain both "inv" and "am". In this example, it returns InvoiceAmount.
This feature is great when you don’t remember the exact name of a method (for example) but remember several of the words, or parts of the words, in the name.
When searching file names, Navigate To searches the full path and file name. For example, type "deb" returns these results:
Figure 4. Navigate To Finds in the Path name.
If you could scroll down this list, you would see every file in my project. That's because the path name to my project includes "deb". Not very helpful.
Use the “@” sign in front of the string to search only the symbols, not the path or file names. If I type "@deb", I get the result shown in Figure 5. Much better!
Figure 5. Use @ to Find Only in Symbols.
Uppercase characters in the search string will cause a case-sensitive search. So if I type "GAS" as shown in Figure 6, it will locate any path, file, or symbol names containing a capital G, A, and S.
Figure 6. Use Upper-Case Letters To Perform a Case-Sensitive Search.
Configuring Navigate To
There are some configuration options for the Navigate To feature. Click the arrow in the Navigate To panel to view the Search options:
Figure 7. Navigate To Search Options.
The first set of items in the drop down list are the last selected navigate to items. This does not include the items you searched; only the results you actually navigated to. Click one of the items to navigate back to it.
The Search options are at the bottom of the list.
Click Search within external items to include or exclude external items, such as files in the External Dependencies folder. (This is for C++.)
Click Use preview tab to turn on/off the ability to preview each search result in the Preview tab.
Click Show details to turn on/off the display of the project and file details for the selection. The details appear at the bottom of the result list as shown in Figure 8.
Figure 8. Navigate To Details.
The details include the project name, full file path, line number of the occurrence and the XML comments for the symbol (if any).
You can also change the size of the Navigate to window so you can see more or less of the results. Just drag the left side of the window to make it wider or narrower. Or drag the bottom to make it taller or shorter.
Use the improved Navigate To feature any time you want to Navigate to a file, class, method, property, or other symbol in your code using some part of the name. Or if you just want to preview that code without leaving your current coding location.
About the author
Deborah Kurata is a software designer/developer and the author of several books, including 'Doing Objects in Visual Basic 2005' (Addison-Wesley), 'Best Kept Secrets in .NET' (Apress), 'Doing Objects in Visual Basic 6.0' (SAMS) and 'Doing Web Development: Client-Side Techniques' (Apress). She is a Microsoft Most Valuable Professional (MVP) and co-chair of the EastBay.NET user group. She speaks at conferences, such as VSLive, DevDays, and TechEd, and writes for MSDN and CoDe magazine. Deborah is cofounder of InStep Technologies Inc., a professional consulting firm that focuses on turning your business vision into reality using Microsoft .NET technologies. Check out Deborah's blog: http://msmvps.com/blogs/DeborahK/