ReSharper, day 10: Go To Type

Welcome to day 10 of my 31 Days of ReSharper.

Today’s topic is Ctrl+N: Go to Type.

ReSharper's Go To Type pop-up

You press Ctrl+N, and a little window pops up. You type in part or all of a type name, and it shows you a list of matches. Then you select one and press Enter, and it opens that file.

The only time you still need Solution Explorer is when you’re adding new files. Other than that, Ctrl+N is about all you need.

And it has shortcut features:

  • Search by title caps. If you type capital letters, it will try to match as if you were typing an acronym. So if you type MDT, it will match MyDataTable and MenuDropTag. (You can mix and match this with ordinary searching, so you could search for MDatT and find MyDataTable.)

  • Wildcards. You can type * to match zero or more characters, or + to match one or more characters. (This is a fileglob-style wildcard; it means “zero or more of any character”.)

Ctrl+N is in fairly direct competition with VSFileFinder; they both do pretty much the same “let me see a list of files matching a particular pattern so I can open one of them” thing. So I figured it’d be interesting to compare the two. Here’s how they stack up:

  • Stuff where ReSharper is definitely better:

    • VSFileFinder doesn’t support the title-caps thing that ReSharper has.

    • Ctrl+N already has a keybinding, whereas I’ve never been able to bind a keystroke to VSFileFinder that survived exiting and restarting Visual Studio.

    • Ctrl+N goes away as soon as you’re done with it, whereas VSFileFinder is a dockable window that keeps taking up space even after you’re done searching.

  • Stuff where VSFileFinder is a little better:

    • Neither tool requires you to know the entire name of the thing you’re searching for; they both let you specify parts of the name. However, VSFileFinder lets you specify those parts in any order; data table would match both DataTable and TableOfData. ReSharper is more limited; you have to specify the parts in the same order they appear in the type name (and you have to remember to type * between each one, instead of being able to just type a space in VSFileFinder).

    • Searching by substring is much easier with VSFileFinder. If you want to find all types that contain “Foo” anywhere in their name, you have to type *Foo in ReSharper, whereas with VSFileFinder you only have to type Foo.

  • Stuff where VSFileFinder is definitely better:

    • VSFileFinder makes it easy to open multiple files at once (precisely because the window is always visible and taking up space). This is a real win for tests — you can type Foo, see both “Foo” and “FooTests” in the list, and click on both of them to open both files. ReSharper doesn’t have this option.

That last item, in particular, illustrates that ReSharper and VSFileFinder are aimed at subtly different goals, and both tools have their place. (We have both of them installed on all of our development PCs.) But of the two, I usually end up using ReSharper’s Ctrl+N. That bit about having a keystroke bound is pretty persuasive.

If for some reason you don’t keep one class per file, you might also be interested in Ctrl+Shift+N, which searches on filenames (instead of type names like Ctrl+N does).

Leave a Reply

Your email address will not be published. Required fields are marked *