ReSharper Help

Template Editor

Template Editor helps creating and editing code templates. Template Editor opens in a new document tab so that you can switch between the template and the application code to quickly test the created template.


Template Editor provides basic code highlighting for keywords, comments, etc. All highlighting colors are configurable.

To configure highlighting colors for Template Editor

  1. Choose Tools | Options in the menu and then go to Environment | Fonts and Colors page.
  2. In the Display items list, find items that start with ReSharper Template Editor.
  3. Use the Item foreground selector to pick a color for the selected item.

The controls in the Template Editor can be divided into two logical groups, which are described in the following two tables:

Template options

Shortcut Available for live templates.
The shortcut (abbreviation) that you can type in your source code to invoke a live template.
Description For surround templates and file templates, this is the identifier that is displayed in the drop-down lists when you attempt to choose and apply a template. For live templates, this is an optional description string that pops up in the completion list together with the template shortcut.
Default file name Available for file templates.
A default name that ReSharper prompts when you apply a file template.
File name must be a valid identifier Available for file templates.
This check box makes ReSharper check if the file name specified when applying the template is valid as a type identifier. This option is helpful if your template creates a file for a new type and the type name is initialized from the provided file name with the Current file name without extension macro. You can check the predefined file templates to see how it is implemented.
Shorten qualified references This check box makes ReSharper automatically insert namespace import directives or remove qualifiers that become redundant after the template is applied. If this check box is not selected, ReSharper will not insert any namespace import directives.
Reformat This check box makes ReSharper automatically reformats the expanded code fragment according to your code style settings.
Availability This hyperlink displays and allows modifying the scope of the template.
Add new file Available for file templates.
This button adds a new empty file to a multi-file template.
Add file from existing template Available for file templates.
This button adds a new file to a multi-file template by the reference to an existing file template.

Template parameters

Parameter name Names of template parameters as they are defined in the template body.
Choose macro or [name of a macro] This hyperlink displays or allows choosing a macro that calculates parameter value. By clicking this hyperlink you can choose a macro in the Choose Macro dialog box. If the selected macro has a parameter, is is displayed in bold in the Choose Macro dialog box (for example, format or type). In this case, after you choose a macro, a text box appears under the parameter. You can specify the macro parameter there.
Editable or Editable occurrence selector These controls allow you to make the parameter editable, in one of the following ways:
  • If the parameter is used in the template only once, make sure that the check-box is selected.
  • If the parameter is used in the template more than once, a combo box appears, where you can select a sequential number of the editable occurrence. This number specifies to which occurrence of the parameter the input focus will be set when the template is deployed with a Hot Spot Session. You may also notice that the numbers a prefixed with 'M' or other letters. These letters define in which file of a multi-file template the input focus should be set for this parameter. 'M' stays for the main file and appears in all templates.
Move Up / Move Down If you select a parameter, you can use these buttons to change the order of parameters. The position in the list of parameters defines the order, in which the parameters are switched during the hot spot session when the template is applied. It affects only editable parameters.

See Also

Last modified: 30 June 2015