Editing Code Templates

You can edit the template code of pre-existing Live Templates, 'Surround With' Templates and File Templates in the Edit Template dialog. The same dialog is used to create a new template from scratch. For details on how to start creating or editing each type of template, please refer to the corresponding help sections:

Edit Template Dialog

A sample Edit Template dialog featuring the "itdic" live template is shown below:


Each template must have a unique abbreviation (see Using Live Templates or Using 'Surround With' Templates for description of use). You will not be able to save the template until a valid unique abbreviation is entered.


The template description appears in templates lists to help you choose the right template.

Template Availability

Specifies the template's availability scope. Click the link to set or modify the template's availability options via the following dialog:

Several choices are available:

Template Text

Template code is defined in this text area. A template may represent just plain text, but it may also contain variables. After the template is expanded, these variables appear in the editor as input fields. Their values can be either entered by the user or automatically calculated by ReSharper.

To declare a variable within the template, use the following format: $<variable_name>$, where <variable_name> represents an arbitrary identifier. When the variable format is correct, it is colored in the template text with dark red as follows: $<variable_name>$.

There are special predefined template variables in ReSharper:

To make ReSharper automatically suggest values for variables in template input fields, you can supply your variables with predefined values or/and with the macro-rules for calculating them. To assign predefined values or/and calculation rules, use the Template variables table (see description below).

Template Formatting

Template Variables

The table contains a list of all template variables (except the special variables). It has the following columns: