4.1. Command Window

As you become more familiar with Visual Studio 2008, you will spend less time looking for functionality and more time using keyboard shortcuts to navigate and perform actions within the IDE. One of the tool windows that's often overlooked is the Command Window, accessible via View Other Windows Command Window (Ctrl+Alt+A). From this window you can execute any existing Visual Studio command or macro, as well as any additional macros you may have recorded or written. Figure 4-1 illustrates the use of IntelliSense to show the list of commands that can be executed from the Command Window. This list will include all macros defined within the current solution.

Figure 4.1. Figure 4-1

A full list of the Visual Studio commands is available via the Environment Keyboard node of the Options dialog (Tools Options). The commands all have a similar syntax based on the area of the IDE that they are derived from. For example, you can open the debugging output window (Debug Windows Output) by typing Debug.Output into the command window.

The commands fall into three rough groups. Many commands are shortcuts to either tool windows (which are made visible if they aren't already open) or dialogs. For example, File.NewFile will open the new file dialog. Other commands query information about the current solution or the debugger. Using Debug.ListThreads will list the current threads, in contrast to Debug.Threads, which will open the Threads tool window. The third type includes those commands that perform an action without displaying a dialog. This would include most macros and a number of commands that accept arguments (a full list of these, including the arguments they accept, is available within the MSDN documentation). There is some overlap between these groups: for example, the Edit.Find command can be executed with or without arguments. If this command is executed without arguments, the Find and Replace dialog will be displayed. Alternatively, the following command will find all instances of the string MyVariable in the current document (/d) and place a marker in the code window border against the relevant lines (/m):

>Edit.Find MyVariable /m /d

Although there is IntelliSense within the command window, you may find typing a frequently used command somewhat painful. Visual Studio 2008 has the ability to assign an alias to a particular command. For example, the alias command can be used to assign an alias, e?, to the find command used previously:

>alias e? Edit.Find MyVariable /m /d

With this alias defined you can easily perform this command from anywhere within the IDE: press Ctrl+Alt+A to give the Command Window focus, then type e? to perform the find-and-mark command.

A number of default aliases belong to the environment settings you will have imported when you began working with Visual Studio 2008. You can list these using the alias command with no arguments. Alternatively, if you wish to find out what command a specific alias references, you can execute the command with the name of the alias. For example, querying the previously defined alias, e?, would look like the following:

>alias e?
alias e? Edit.Find SumVals /m /doc

Two additional switches can be used with the alias command. The /delete switch, along with an alias name, will remove a previously defined alias. If you want to remove all aliases you may have defined and revert any changes to a predefined alias, you can use the /reset switch.

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

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