Thursday, August 19, 2010

Keyboarding: VS2010 Navigate To Inside-Out

Keyboarding is a series of blog posts related to programming productivity sometimes including looking at ways to keep your fingers on the keyboard and away from that mouse!

The Chase: The Navigate To Dialog in VS2010 lets you navigate to files, classes, properties etc. in your current project simply by hitting CTRL+, then typing a portion of the entity’s name. Hit enter to go to the 1st entry or use arrows to navigate through the results.



Mo' Tips

Pascal-Case enhanced search

Navigate To a Path

Filter By Extension

Explicitly Specify Class Scope


Main Commands

Search Filters

Closing Notes


We all love windows 7 right? Don’t you love being able to hit WIN + part of the filename you’re looking for and see it pop up in the desktop search? Microsoft really did a great job there. But then, why would MS hang their developers out to dry when it comes to visual studio? In the pre-VS2010 era developers were relegated to use the solution explorer to find files and open them. This required expanding and contracting folders, sometimes several levels deep, to get to the file you want. It’s even worse if you hide the solution explorer pane for more screen real estate. Long story short, good type-ahead search in windows and on the web has spoiled us for good keyboard-friendly search in our code too!

Thus, Visual Studio 2010 came to the rescue! VS2010 includes the new “Navigate To” dialog which is easily invoked when you have a project open by typing CTRL+,. We’ll grep the MVCMusicStore example app by John Galloway since it has a rich set of file types to show off some of the “Navigate To” dialog’s hidden features. Anyway, it’s always a good exercise to read other people’s code.


Here I am, a beautiful blank Visual Studio with the MvcMusicStore solution open, how do I get started? Well, those familiar with MVC know that the core of most applications is in the controllers, let’s look for some controllers!


Wunderbar! I’m already presented with a list of related classes, methods and files with the word controller in them. This is a “LIKE” search so anything that contains your search term will be included in short:


Fact: The Navigate To Dialog will return results including:

  • Classes
  • Methods
  • Properties
  • Member Variables (public and private)
  • Files

Fact: if you hit ENTER while typing in the Navigate To dialog it will (he he!) Navigate To the 1st result, if you arrow up or down it will naturally go to whatever entity you select.

For fun let’s try something like Album, since that’s one of the common domain objects in this project (a music store)


You’ll notice this returns a more diverse (and larger) set of results including code and markup files, very handy for when you simply want to open a file.

Of course if you type in something more specific the results will be filtered thusly:


(Side note: ALT+N+SC is a neat keyboard shortcut to bring up the insert screenshot menu in Word 2010)

So now when I want to start developing I can just do WIN, solution file name, ENTER then CTRL+, then the filename ENTER and BAM! Off you go!

Now this is just the basics of course, but here are a few extra tips that aren’t as well known:

Mo’ Tips

Pascal-Case enhanced search:

Just like the new and improved intellisense in VS2010, the Navigate To dialog can save you keystrokes by using the PascalCasingConvention.


Simply type AMS for AccountMembershipService. This tip is pretty well known; hopefully the following ones will show you something new

Navigate To a Path

For the command line enthusiasts out there, you can type your way through a path much quicker than you can click through a set of folders, so if you have a specific path or file you want to open up via the Navigate To dialog, you can just prefix your search with a \ and it will filter your search by the subsequent paths you type in see:





A few things to notice here:

- Use lowercase when you want to do path/file exclusive searches, once you start with casing it invokes its intellisense-ish camel-case search.

- Typing \ will list all files in your project

- If your search ends with a \ it will filter by the path preceding it, whereas if you have {path}\{filter} it will filter all files under the path according to the specified filter (see the last two images). This is useful in MVC projects where you may have many files with the same name, say “Details.aspx” but you may want to jump to one in a specific folder “\views\store\details.aspx”

Filter By Extension

While the Navigate-To dialog doesn’t support wildcards, you can easily filter for a specific type of file by simply typing the appropriate extension




Obviously it’s not perfect ; )


Explicitly Specify Class Scope

You can specify a class scope by specifying the {class name}::{filter}. As far as I can tell this feature is C++ only, which is a shame and also perplexing.



See how it brought up all my Photon related methods? This code is from a ray tracer I wrote for a school project =)

I hope these tips have been helpful, here’s a handy reference


Main Commands

CTRL + , : Open the Navigate To Dialog

ENTER : Opens the 1st item in the list or whichever item was selected using the up/down keys or mouse

ESC : Close the dialog

Search Filters




Example Results




Classes, Methods, Properties, Members, and files containing *{filter}*

Cart [class]

CartCount [property]

CartSummary.ascx [file]

AddToCart(int) [method]


{Uppercase Member Initials}


Members that match the Camel Case expansion of this

AccoutMemberShipService [class]

AccoutMemberShipService() [method]

AccoutMemberShipService(…) [method]

Use uppercase letters



List of files matching the search filter under the path \{dir1}\{dir2}\...

Browse.aspx (\Views\Store)

Create.aspx (\Views\StoreManager)

GenreMenu.aspx (\Views\Store)

Index.aspx (\Views\Store)

Always use lowercase letters to invoke path search instead of PascalCaseSearch.

Typing \ will list all files in your project.

If you end your path with a \ it will list all the files in the path preceeding the slash.



List of files with provided extension




Doesn’t completely work, but in general it gets the job done.

{Class or Namespace}::{filter}


Lists all members within the prefixing class or namespace




Seems to be C++ only

You can filter namespaces/classes recursively NS1::NS2::Class etc.

Closing Notes

All in all, Navigate To is a great way to navigate between files and classes and other entities in your project easily from your keyboard. If you like staying on the keyboard it’s even quicker than switching to another tab in some cases and is a big improvement over navigating the solution explorer. You can even navigate through your project’s file structure by typing out paths in the search box.  This can be real handy in day to day coding or in a pinch when you’re looking for a specific method/file etc. like when you’re in a code review.   Some nice additions would be autocomplete of class names / folders when navigating through deep structures and allowing the same type of namespace/class scoping that the C++ navigate to dialog offers.

Thanks for reading! Know any more ninja-tips for the Navigate-To dialog or have any questions? Leave them in the comments! We love feedback!

- T.J.B.

No comments:

Post a Comment