Add Code Template

Top  Previous  Next

The Add Code Template feature allows you to create code snippets that you insert frequently in your source code. The code templates are created in the Corporate Options window, Add Code Template section. When you invoke this feature, the Code Template Selection window is shown:

CodeTemplateSelection

MZ-Tools offers the following ways to show the dialog window with the list of code templates that you can add to the source code:

  • The MZ-Tools | Add Code Template... menu.
  • The Add Code Template... button on the MZ-Tools toolbar.
  • The keyboard shortcut associated with the MZTools6_VSXXXX.AddCodeTemplate command.

The window to select the code template shows the code templates grouped by the Category field of each code template.

In addition, since a Visual Studio command is created for each code template, you can associate a customized keyboard shortcut to each code template that inserts directly the code template into the source code without using the selection window.

You can also insert code templates through expansion keywords (a short word that you type in the code window when you want to insert its associated code template). To use this functionality:

  • Associate a customized keyboard shortcut to the MZTools6_VSXXXX.ExpandKeyword command (see Keyboard Shortcuts Options).
  • Associate an expansion keyword to the code template (see Template Properties)
  • Type the expansion keyword in a text file and press the keyboard shortcut created in the first step. If the keyword is recognized, it will be replaced by the associated template.

Code templates can include:

  • Predefined variables (such as the author, current date, procedure name, cursor position after insertion, etc.)
  • User-defined variables, that is, your own variables. When you insert in the source code a code template with user-defined variables, a dialog asks you the values of those variables.

See Also:

Add Code Template Options

Keyboard Shortcuts Options

Template Properties