Share via


Argument Macros

Home Page (Customizing)OverviewHow Do I ... Topics

You can use argument macros to specify arguments for a Tools menu command. Visual C++ provides the argument macros shown in the following table.

Macro name Expands to a string containing
$(CurCol) The current cursor column position within the active window.
$(CurDir) The current working directory (defined as drive+path).
$(CurLine) The current cursor line position within the active window.
$(CurText) The current text (the word under the current cursor position, or a single-line selection, if there is one).
$(FileDir) The directory of the current source (defined as drive+path); blank if a nonsource window is active.
$(FileExt) The filename extension of the current source.
$(FileName) The filename of the current source (defined as filename); blank if a nonsource window is active.
$(FilePath) The complete filename of the current source (defined as drive+path+filename); blank if a nonsource window is active.
$(TargetArgs) The command-line arguments that are passed to the application you are developing. To set these command-line arguments, type the argument in the Program Arguments box on the Debug tab accessed by the Settings command on the Build menu.
$(TargetDir) The directory of the current target (defined as drive+path).
$(TargetExt) The filename extension of the current target.
$(TargetName) The filename of the current target (defined as filename).
$(TargetPath) The complete filename of the current target (defined as drive+path+filename).
$(WkspDir) The directory of the current workspace (defined as drive+path) that contains the .DSW file; blank if no workspace is currently open.
$(WkspName) The current workspace name (defined as filename) without the .DSW extension; blank if no workspace is currently open.

Notes   Macro recognition is not case sensitive. All path macros end in a backslash (\).

To use a macro as an argument, type the macro name in the Arguments box. Or, for macros that expand to a directory, you can type the macro name in the Initial Directory box.

To add an argument macro to an installed tool and then run it

As an example, the following procedure demonstrates how to add the $(FilePath) argument macro to the Windows Notepad accessory.

  1. On the Tools menu, click Customize and click the Tools tab.

  2. In the Menu Contents box, select the command that you want to edit. In this case, select the Notepad accessory that you installed earlier.

  3. In the arguments text box, type $(FilePath) or select the drop-down arrow to the right of the Arguments box to display a list of Arguments and then click Close.

  4. To see your changes, on the Tools menu, click Notepad. The Windows Notepad accessory opens, with the active source file as its text file.

What do you want to do?

Learn about error syntax for tools

Customize the Tools menu