Template Properties

Top  Previous  Next

The Code Template window allows you to create or edit a code template:

CodeTemplate

For each template you can set the following properties:

  • Description: a friendly name for the template.
  • Command Name: the name of the Visual Studio command that MZ-Tools will create associated with this template. This command is useful because you can assign a keyboard shortcut to it as you do with regular, built-in Visual Studio commands (Tools, Customize... menu, Keyboard... button) and you can also drag the command to a toolbar if you wish.
  • Expansion Keyword: this property allows you to type a word associated with a template (such as some initials, for example) and then get the word replaced by the full template when triggering the expansion through the keyboard shortcut associated to the MZTools6_VSXXXX.ExpandKeyword command. To use this expansion mechanism for code templates follow these steps:
  1. Click the Tools, Customize… menu.
  2. Click the Keyboard… button.
  3. Locate the MZTools6_VSXXXX.ExpandKeyword command in the list.
  4. In the Press shortcut keys textbox, enter some combination of keystrokes. Ensure that the Shortcut currently used by textbox is empty.
  5. Click the Assign button and close all dialog windows.
  6. In a code window, type the expansion keyword associated with a code template.
  7. While the cursor is at the end of the typed expansion keyword, press the keyboard shortcut defined in the step #4. The expansion keyword should be recognized and replaced by the text of the template.
  • Category: this property allows you to group templates. When you are going to add a template to a file and you have more than one template, a dialog window is shown to allow you to select the template that you want to use. In that window, the templates are grouped by categories.
  • .NET Language: the template can be added to files in any .NET language or only to files whose code is written in a specific .NET language.
  • Text: the text of the template.

You can use the Insert > button to add two kinds of variables to the text of the template:

  • Predefined variables: these are variables whose values are replaced by MZ-Tools just before inserting the template in the text document. For example, the file name, the current date, etc. See Predefined Variables.
  • User-defined variables: these are variables that you can create with your choice of name. You will be asked to supply the value of the variable(s) just before the template is inserted into the document.

See Also:

Add File Header Options

Add Class Header Options

Add Procedure Header Options

Add Exception Handler Options

Add Code Template Options

Predefined Variables