Find Combo Box

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 ...".

Find Combo Box Runs Commands

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.

Tip 6.16: How to have fun with the Find combo box

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.

Get help

You can read Shawn’s full blog post at http://blogs.msdn.com/shawnfa/archive/2004/02/27/81338.aspx.

Tip 6.17: You can press Ctrl+/ to run Visual Studio commands in the Find combo box

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.

Sara Aside

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.

Tip 6.18: How to open a file in the solution without using either a tool window or a dialog box

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 ...

  1. Press Ctrl+/. This brings you the Find combo box with the ">" already included for you.

  2. Type File.OpenFile <filename>. You’ll notice support for autocompletion.

  3. 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:

  1. Press Ctrl+/.

  2. 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:

  1. Press Ctrl+/.

  2. Type fo <filename>.

Sara Aside

And now your file is opened in the editor. Tool windows and dialog boxes are not required.

Tip 6.19: You can set a breakpoint on a function from the Find combo box

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?

Tip 6.19: You can set a breakpoint on a function from the Find combo box

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.

Tip 6.19: You can set a breakpoint on a function from the Find combo box

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().

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.123.155