Share via


Visual Studio Commands and Switches

Visual Studio commands allow direct interaction with the integrated development environment (IDE) from the keyboard. Many dialog boxes, windows, and menu commands within the IDE have a command-line equivalent that you can type into the Command Window, the Immediate Window, or the Find/Command Box to display a dialog box or execute a command.

Visual Studio commands follow certain general syntax rules that are explained below. The set of available commands includes all commands listed in the Keyboard, Environment, Options Dialog Box and on the Commands Tab, Customize Dialog Box (Visual Studio), as well as user-defined aliases and macros.

Building from the Command Line

For information on building projects in Visual Studio programming languages from the command line, see Building from the Command Line (Visual Basic), Command-line Building With csc.exe (Visual C#), VCBUILD Options (Visual C+), and Building from the Command Line. For information on configuring an MSBuild XML schema file to build projects, see the MSBuild Reference.

Visual Studio command syntax

Visual Studio commands can be entered in the Command window, Immediate window, or Find/Command box. In each case, the greater than sign (>) is used to indicate that a command rather than a search or debug operation is to follow.

For detailed information on command syntax, see Visual Studio Commands with Arguments and Devenv Command Line Switches.

Many commands can be written in either of two formats, using the complete command syntax or a shorter form or alias.

Complete command names

The complete syntax for commands is based on the full command name listed Keyboard, Environment Options dialog box. In most cases, the complete syntax reflects the placement of commands in the IDE menu system. Complete command names adhere to the following syntax rules:

  • Command categories, such as menus, and command names are separated by a period (.).

  • Spaces and punctuation are removed from all command names as displayed on the menus.

For example, the command that displays the New File Dialog Box appears in Keyboard, Environment Options as a child of the File command. To display this dialog box, type the following command into the Command window, Immediate window, or Find/Command box and press ENTER.

>File.NewFile

The New File dialog box appears, ready for you to make your selection.

Command aliases

You can create short names, or aliases, for complete command names to help you remember and enter the commands more quickly. Visual Studio comes with a set of pre-defined aliases. For example, the command that displays the New File dialog box has the default alias nf. For more information, see Predefined Visual Studio Command Aliases.

You can also create your own custom aliases or change pre-defined aliases by using the alias command. For example, you can create an alias for the command Edit.MakeUpperCase by entering the following:

>alias upper Edit.MakeUpperCase

The next time you select text in the editor and enter >upper in the Command window, Immediate window, or Find/Command box, the text will appear all in capital letters. You can also create aliases that include command names and their arguments.

To display a list of all current aliases, enter the following command in the Command window:

>alias

Commands with arguments

Some commands allow you to provide arguments, such as file names or switches that execute a command, without displaying any dialog boxes or other user interfaces. For example, the command File.NewFile, entered without switches, displays the New File dialog box. You can also create a new file from a template, without displaying the New File dialog box, by including the /t switch. The following example creates a new text file, called Mytext.txt, based upon the "General\Text File" template, and opens it in the source code editor.

>File.NewFile Mytext /t:"General\Text File" /e:"Source Code (text) Editor"

Note

Command arguments must be entered in the order specified for the command. Switches and their arguments can be placed in any order.

Commands and arguments adhere to the following syntax:

  • Command names and arguments are separated by spaces

  • Argument values that contain spaces must be enclosed in quotation marks

  • Use the caret (^) character for escape characters

  • Single-character argument abbreviations can be combined. For example, you can combine the single character argument abbreviations for /case (/c) and /word (/w) as /cw instead of /c /w.

Many command name switches have both full and short names that can be used interchangeably. For example, the /case switch of the Edit.Find command can also be written /c. For a complete list, see Visual Studio Commands with Arguments.

Escape Characters

A caret (^) character in a command line means that the character immediately following it is interpreted literally, rather than as a control character. This can be used to embed straight quotation marks ("), spaces, leading slashes, carets, or any other literal characters in a parameter or switch value, with the exception of switch names. For example,

>Edit.Find ^^t /regex

A caret functions the same whether it is inside or outside quotation marks. If a caret is the last character on the line, it is ignored.

Auto completion for commands

The Command window, Immediate window, and Find/Command box provide auto completion when you enter command names and aliases. The auto completion list displays all possible matching command names and aliases, whether or not the command is currently available. If you enter or select an unavailable command, the status bar displays the message, "The command is not available" and the command is ignored.

International command names

In localized versions of the IDE, command names can be entered either in the native language of the IDE or in English. For example, you can type either File.NewFile or Fichier.NouveauFichier in the French IDE to execute the same command.

Macro names are similar to command names. Although you can save macros using a localized name, for better compatibility between English and localized versions of Visual Studio, it is best to save macros using English names. This is because all localized versions of the IDE understand English commands, but not all localized versions of the IDE understand a different localized language.

See Also

Reference

Command Window

Immediate Window

Find/Command Box

Predefined Visual Studio Command Aliases

Visual Studio Commands with Arguments