#91 fun with the Find Combo Box

It’s time for an old favorite from the Visual Studio 2005 days…

Remember How to search using the Ctrl+D Window from one of the earlier tips?  Now let’s have a little more fun…

Press Ctrl+D to go to the Find Combo Box and then…

Goto 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) 
Goto a file – type the name of the file (either in your project or on the INCLUDE path)and press Ctrl+Shift+G
Set a breakpoint on a function – type the name of the function and press F9
Get help – type the keyword and press F1

And to continue from yesterday’s tip on command aliases

To get a callstack – type “> kb”
To go to a webpage – type “> nav http://www.microsoft.com

 

#90 Create a command alias

To create an alias, open up the Command Window (or anywhere you can type in VS commands) and type in something along the lines of

alias GobblesGobblesGobbles help.about

Command Window creating aliases

and now running GobblesGobblesGobbles from the VS command window will pop up the Help About menu.  I will award bonus points if you can figure out the Gobbles reference.  =)

But let’s explore a more practical application….

alias se View.SolutionExplorer

Now you can just type se to jump to the solution explorer.  For this particular example, the idea is you can be typing in the editor, press Ctrl+/ to jump to that Find window that can act as a command window, and type in se.

Actually, you’ve probably already used one of the predefined aliases before. Debug.Print is alias to ‘?’.  To see the full list of aliases, type in

alias

predefined aliases

Lastly, to reset your command window aliases back to defaults, type in

alias /reset

Reset aliases warning prompt

or just simply use the /delete switch to delete a particular alias, like alias se /delete.

 

#89 Run external executables from the VS command line

The command Tools.Shell will run an external executable out of process from VS.  To run, it is basically

Shell <executable>

But of course, we got optional arguments…

Shell [/commandwindow] [/dir:folder] [/outputwindow] <executable> [/args]

/commandwindow (or /c) – to display the executable’s output in the command window

/outputwindow (or /o) – to display the executable’s output in the output window

/dir:folder – specifics the working directory

For example,

Shell /o /c xcopy.exe c:\users\saraf\documents\cmdwinlog.txt c:\users\saraf\pictures

will display the xcopy output in the output window.

output redirected to the output window

#88 Log your command window session

You can record your command window session via the log command.  Just run

log -on <filename>

and start recording.  To finish logging, it’s just

log -off

There is also an option to overwrite the existing file; otherwise it will append.  Note that both dash and forward slash will work for command arguments. 

Command Window displaying logging commands

#87 Run Visual Studio commands with arguments from the command window

After the past several weeks of Find tips (i knew i would have a few tips, just not nearly a month’s worth!), let’s change things up a bit and talk about the command window.

Press Ctrl+Alt+A to open the command window.  Check the keybinding for View.CommandWindow if your keybindings are different.  Also available from the View – Other Windows – Command Window.  Now you can run various Visual Studio commands without having to go through the menus. 

Examples:

>File.Open c:\samples\foo.txt  //Open a file without going through the menu. 
>Help vs.commandwindow  //open a help topic directly
>? i  // get the contents of the variable i
>? i = 10  // set the contents of the variable i

View the following help topic for a list of commonly-used commands that include arguments in VS 2005.  Also available in VS 2008 documentation.

Auto-completion is also provided for both the commands and their corresponding arguments.

Command Window Auto-completion for commands

You can also get auto-completion for arguments. 

Command Window Autocomplete for Arguments