It wasn’t until I took over testing the editor that I learned that the Find combo box runs Visual Studio commands. And it wasn’t until I found Tip 6.16: How to have fun with the Find combo box that I learned that the Find combo box can combine keyboard shortcuts and command arguments.
I feel like this section is really a collection of tricks, as these tips truly embrace the spirit of "Did you know ...".
This section describes all the things you can do with the Find combo box to run commands, like getting help for a particular keyword, opening a file without any UI, or setting a breakpoint on a given function name.
Following are some examples of commands you can run from the Find combo box, but the idea is that many Visual Studio commands take parameters that you can enter into the Find combo box. Hit the keyboard shortcut to a Visual Studio command, and the command will pull its parameters from the Find combo box.
Press Ctrl+D to go to the Find combo box. Now here are a few ways you can have some fun:
Go to a line. Type the line number, and press Ctrl+G. I like showing this off as how you can do a "go to line" without popping up the Go To dialog box.
Go to a file. Type the name of the file (either in your project or on the INCLUDE path), and press Ctrl+Shift+G.
Get help. Type the keyword, and press F1.
You can also use command aliases, as shown here:
To get a call stack, type >kb.
To go to a Web page, type >nav http://www.codeplex.com.
You can read Shawn’s full blog post at http://blogs.msdn.com/shawnfa/archive/2004/02/27/81338.aspx.
Press Ctrl+/ to reach the Find combo box; the ">" will be inserted for you. Of course, you could press Ctrl+D and then type > if you really wanted to.
It’s like Microsoft IntelliSense, but for Visual Studio commands instead.
Note that you may need to use a different keyboard shortcut, depending on which environment settings you are using. If Ctrl+/ does not work for you, go to Tools–Options–Environment–Keyboard to see what keyboard shortcut the Tools.GoToCommandLine command is bound to.
The idea here is you just want to press some keyboard shortcut, type the file name that’s in the solution, and go directly to that file. No Solution Explorer. No Open File dialog box. No UI.
Here we go ...
Press Ctrl+/. This brings you the Find combo box with the ">" already included for you.
Type File.OpenFile <filename>. You’ll notice support for autocompletion.
Select a file, and press Enter to open the file.
Because the command File.OpenFile seems to me to be very long to type, you can use the following steps to create an alias that is shorter:
Press Ctrl+/.
Type alias fo File.OpenFile to create a command alias.
Now, for the rest of time or until you reset your command aliases, you can:
Press Ctrl+/.
Type fo <filename>.
And now your file is opened in the editor. Tool windows and dialog boxes are not required.
In the standard command bar, you’ll see the Find combo box right next to Find In Files. Obviously, you can type a function name and hit Enter to search, but where’s the fun in that?
Type the name of the method, as I have in the preceding screen shot, and hit F9. You’ll notice the breakpoint is set at function Main.
Why did this happen?
F9 is bound to a command called Debug.ToggleBreakpoint. If there’s text in the Find combo box and you run a Visual Studio command from within the Find combo box, the IDE will use that text as the command parameter. In the case of F9, the IDE toggled a breakpoint at the specified function, hence setting a breakpoint at Main().
3.144.47.208