The Command Window

The Command Window, like the Immediate Window, can be one of those tools that a developer can find to be an invaluable aid and time saver. As the name implies, the Command Window is essentially a shell into Visual Studio and provides a mechanism other than point-and-click to activate and use Visual Studio’s features.

To start things off, the Command Window (if not already present) can be brought up by using the “Control-Alt-A” keystroke in Visual Studio 2005 and “Control-W A” in Visual Studio 2008.

Though it is available at all times to the developer, lets start off in Debug mode (where I use it the most). For example, you can mimic the Immediate Window by using the Debug.Print command (shown here using the eval and ? shortcuts):

command1.png

But statement evaluation is just scratching the surface. For example:

command5.png

Here we can see all the active threads going using Debug.ListThreads.

And of course, IntelliSense is supported:

command4.png

Outside of Debug mode, almost all of the actions that you would normally perform through the UI via the mouse or keyboard shortcuts, are available via the Command Window. For example, opening a file:

command2.png

Personally I hate taking my hand off the keyboard. With this, you can issue Control-Alt-A to open (or request focus) the Command Window up, type in your commands, and then hit Escape focus is back (most of the time :)) in your editor.

Some useful shortcuts/utilities built into the window:

  • ?? (Debug.QuickWatch) — for example ?? x will setup a QuickWatch on x
  • ? (Debug.Print) — as shown above, (evaluate and) Print an expression
  • ~ (Debug.ListThreads)
  • t (Debug.StepInto)
  • alias — define your own alias
  • log — log Command Window output to a file. For example, log /on C:\Debug.txt turns on logging and log /off turns logging off.

Plus a lot more. I don’t think this post did the power of this feature justice, but the following links can give you a lot more information:

Do you have any good tips or tricks using the Command Window? If so, leave an comment and I will update this post.

kick it on DotNetKicks.com

5 Responses to “The Command Window”

  1. DotNetKicks.com Says:

    Command Window…

    You’ve been kicked (a good thing) - Trackback from DotNetKicks.com…

  2. Sam Says:

    Wow! I will bookmark this. I could never figure out the command window. I thought it might be some kind of terminal

  3. Dew Drop - March 14, 2008 | Alvin Ashcraft's Morning Dew Says:

    [...] The Command Window (nillfm) [...]

  4. dvilchez.net » Blog Archive » Algunos links Says:

    [...] eso de silverlight: Desensamblando un proyecto Silverlight 2.0 Beta 1 Esas herramientas perdidas: The Command Window Windows tambiƩn tiene shell: The Windows Command Line, Batch Files, and Scripting Por todos los [...]

  5. Wöchentliche Rundablage: ASP.NET MVC, Silverlight 2, LINQ… | Code-Inside Blog Says:

    [...] The Command Window [...]

Leave a Reply