Navigate To (aka Quick Search)

One of the new features of Visual Studio 10 is the Navigate To feature (previously called Quick Search). I could write a whole article about the discussions around the naming but at least for now we’re sticking to Navigate To (with the disclaimer being that as of today this is not final). The first thing that comes to mind if you haven’t seen this feature elsewhere is… why does Visual Studio need another search feature? The answer to that is actually a simple one; this is not your ordinary text search for a search for different elements on your solution which can include code elements, files and pretty much anything that you can think of thanks to the extensible model.

 

How many times did you find yourself using Find to look for a function and end up getting every call to that function? Yes, there’s other ways of getting there such as using Class View for example but you want to get there as fast as possible. A more extreme scenario in the C++ world be working on a project that has a ton of dependencies and you need to get to a function declaration that’s on an external header file. With this new feature you can do this with a few keystrokes.

 

I’ll get into the details in a bit but if you just want to start using the feature right now skip the next or you can look at this or this blog posts from the VB team which contains a simple walkthrough of how to use the feature.

 

The model

 

The way the feature works is through the aggregator which intercepts the search and navigate calls and passes these along to the active providers. The providers handle the search for their specific associations (i.e.: C#, VB, C++, files). In addition to those four providers which will be shipping with Visual Studio anyone can write their own providers to extend the functionality. This means that if you use Visual Studio for writing code in a different language you can write a provider that handles searches for your preferred language and hook it to Visual Studio. It doesn’t has to even be for something that you compile using Visual Studio, let’s say you like using Visual Studio to write scripts you can write your own provider to handle search on files associated with scripts. The documentation on the providers is not yet finalized so I won’t go into detail about how to implement your own provider (I’ll save that for a later post).

 

Aggregator

Providers

Visual Basic

C#

Customized

C++

Filename

Search Term(s)

Search Results

Using the feature

 

The feature is accessible one of two ways:

- Through the menu under Edit:

- And as you can see in the menu through its shortcut Ctr + ,

 

 

 

After you the window is up you can start searching. Here’s the results from a solution that contains C++, VB, and C# projects:

 

 

 

One of the features which is more tailored for C++ users is the Hide External items filters (the checkbox at the bottom left of the window). This will only display results from tokens in your project as opposed to having results from both your project and its external libraries. Take a default MFC application for example before and after filtering (notice how the result count goes from 502 items to just 7):

 

 

 

Once you find the result you’re looking for you can navigate to it by either double clicking on the item, pressing ok or simply pressing enter and it will open on the appropriate editor on your Visual Studio instance.

 

You probably noticed from the screenshots that the search box is actually a drop down. This drop down saves the searches for the current session.

 

 

 

Another of those small things you will get used to and love really quick is the fact that it works in the same way as find in the sense that it prepopulates itself with the term on which the cursor was at before being invoked. So for example if I was declaring an instance of a CChildFrame class and invoked the window in the middle of it it would already have that as its search term:

 

 

 

 

I’ll be the first to admit that if the feature is completely new it takes some time getting used to not search by things by using Find. Once you do get to it though you’ll wonder how did you ever worked without it. Without a doubt this is the feature I’m most excited about on this release.