The Talented Mr. Edit.GoToFindCombo

In the movie The Talented Mr. Ripley, Matt Damon plays Tom Ripley, “a young underachiever”. Ripley is gifted at improvisation and impersonation, but he takes an obsession too far.

Apparently our Visual Studio friend the “Go To Find Combo” (weird name, I know–from this point on I’m just going to call the dang thing the “Find” combo) is like Mr. Ripley–adaptive, talented, and full of secrets. If you don’t recognize it by name, the “Go To Find Combo” is the “Find” combo box in the Standard toolbar. (Shortcut: CTRL+/ or CTRL+D, depending on who you believe.)
Visual Studio Go To Find Combo

In the recent Mastering .NET Debugging class I took, John Robbins clued us in to some of the crazy stuff this combo can do. I’m sure under the covers in the key processing code for this dialog there’s a huge “if/else if/else” statement. Just kidding.

Find

Okay, this is what we all know it does. Type in a search term, press enter, and it searches within the current document. Or press the “Find in Files” button (image) and it will display the Find in Files dialog with your search term pre-populated. It probably does so much more relating to searching, but that’s primarily how I use it.

Open A File By Name

Type the name of a file into the “Find” combo, then press CTRL+SHIFT+G (“Open File”), it will find and open the file you specified.
image
(Imagine me pressing CTRL+SHIFT+G in the screen shot above)

Create a New File By Name

Similar to opening a file, create a new file by typing a file name into the “Find” combo and pressing CTRL+N (“New File”). A new file with the specified name will be opened, but it’ll be up to you to save it to the correct place.

Set Breakpoints Instantly

Probably the coolest “hidden feature”, type the name of a Method into the “Find” combo and press F9. Notice that a breakpoint was automatically set on the opening brace of the method! And, if you’ve got overloads, notice that a breakpoint was set on every overload. For example, let’s say I have a “Show” method that has 3 overloads. Typing “Show” and pressing F9 sets these breakpoints:

image

But check out just how talented Edit.GoToFindCombo really is… using my example above, I’m going to type in “Show(Control)” and press F9 to set a breakpoint specifically on the Show(Control control) method. What happens?

 image

It sets a breakpoint on both the Show(IWin32Window) and Show(Control) overloads. Why? Because the Control class implements the IWin32Window interface! So my “search term” for the breakpoint matched two possible overloads, and it was smart enough to know that. Great stuff.

Commands

Anything you can type into the command window you can also type into the Find combo. Just prefix it with “>” and intellisense will guide you. For example, to open a file, type “>open ” plus the first letter of a file. Or you can execute macros, etc. The sky is the limit!

image
Execute a command window command

image 
Execute a macro, custom or otherwise

Update: Sara Ford shows us one more useful feature. Type in a line number and press CTRL+G to jump to the line. Is there no end to the madness?? :)

This entry was posted on Tuesday, September 11th, 2007 at 5:30 pm and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

11 Responses to “The Talented Mr. Edit.GoToFindCombo”

  1. John Sheehan Says:

    >of does the same as >open. Are these commands documented anywhere?

  2. aaron Says:

    Yep, they’re documented here:
    http://msdn2.microsoft.com/en-us/library/c3a0kd3x(VS.80).aspx

    And, here’s a good tip from that page:
    “Type >alias in the Command window to display a list of the current aliases and their definitions. Type >cls to clear the contents of the Command window.”

  3. Stupid Visual Studio Trick, Part 3 « Just Sayin’ More Words Says:

    [...] Here’s another post outlining even more tricks with the Find [...]

  4. Quickly Find/Open a File in Visual Studio » Alteridem Consulting Says:

    [...] After this post made the front page of DotNetKicks, Aaron Lerch wrote a post on his blog with more things that you can do with the find combo. One thing that is very useful is [...]

  5. Rob Prouse Says:

    Great post. It is much more informative that the one I posted at http://www.alteridem.net/2007/09/11/quickly-findopen-a-file-in-visual-studio/, so I made an update and linked back to this one.

  6. .Net Adventures : Interesting articles (September 15) Says:

    [...] The Talented Mr. Edit.GoToFindCombo by Aaaron Lerch [...]

  7. Opening a VS item's directory in Explorer - dave^2=-1 Says:

    [...] There seems to be quite a lot of cool crouching-tiger-hidden-features in VS 2005 (i.e. features that are not very discoverable). [...]

  8. Opening files from the VS "Quick find combo" - Wes' Puzzling Blog Says:

    [...] if that wasn’t enough Aaron Lerch posted The Talented Mr. Edit.GoToFindCombo which lists some other cool features of the “Quick find combo”. Published Wednesday, March 26, [...]

  9. Danie Says:

    For some reason the “Find” is not in the Standard Toolbar. Any Ideas?

  10. Marius Bancila’s Blog » Blog Archive » The Find Combo Box from Visual Studio Says:

    [...] blog post describes several other commands such as opening and creating files and setting breakpoints. The [...]

  11. Suresh R Iyer Says:

    After some struggle to recreate the behaviour I had in VS2005 in VS2008, understood the importance of Tools.GoToCommandLine and the difference between Tools.GoToCommandLine and Edit.GoToFindCombo. We need to map both Tools.GoToCommandLine and Edit.GoToFindCombo. The former ensures that the FindCombo turns into a [mini] command window, and this means you get the command prompt “>” inserted for you, and this auto insertion really makes a difference, believe me.

    In VS2008 I had wrongly mapped Ctrl+/ to Edit.GoToFindCombo and was typing the “>” everytime to turn on the command mode. Not anymore. Ctrl+/ is mapped to Tools.GoToCommandLine. Ctrl+Shift+/ is mapped to Edit.GoToFindCombo. I am using Visual C# keyboard bindings and under this mapping, binding Ctrl+D to Edit.GoToFindCombo is not a great idea.

    To summarize, map

    Tools.GoToCommandLine Ctrl + /
    Edit.GoToFindCombo Ctrl + Shift + /

Leave a Reply