Template Editor is a new user interface for editing ReSharper templates introduced in ReSharper 4.0. It opens in a new Visual Studio code
pane, allowing you to switch between your code and your template editing environment to make real-world testing of templates
faster:
The following two tables describe controls in the Template Editor that can be divided into two logical groups:
-
Template Options : general template controls above the text editor. -
Template Variables : the list of template variables to the right of the text editor.
Template Options
| Item | Description | Comments |
| Shortcut |
In this field, you should specify the shortcut (abbreviation) that you can type in your source code to invoke the template. |
Available for live templates. |
| Description |
For surround templates and file templates, this is the identifier that is displayed in drop-down lists when you attempt to choose and apply a template. For live templates, this is the description string that is displayed in drop-down lists to the right of a template shortcut. |
Available for all three types of templates. |
| Default file name |
Type a default name that ReSharper will suggest in the Create [template description] dialog box when you apply the template. |
Available for file templates. |
| File name must be a valid identifier |
If this check box is selected and the default file name that you entered doesn't meet requirements for valid identifiers, ReSharper displays an error message in the Create: [name of template] dialog box when you attempt to apply the template. |
Available for file templates. |
| Available... |
By clicking the link, you specify availability scope for the template in one of two dialog boxes:
|
The following options are available in the Template Availability dialog box:
The following options are available in the Template Options dialog box:
|
| Shorten qualified references |
Select this check box if you want ReSharper to automatically remove redundant references in method calls for which necessary namespace import directives have been inserted. |
|
| Reformat |
Select this check box if you want ReSharper to automatically reformat the deployed template according to your code style settings. If the check box is cleared, ReSharper will only indent the whole template according to the code position where it was deployed, which leaves its formatting unchanged. |
Template Variables
| Item | Description | Comments |
| Name |
In this column, names of template variables are initially displayed in the same order that they appear in the Template text section. You can
|
|
| Value |
In this column, you can view or edit values and/or macros that ReSharper uses to suggest values when deploying the template. |
If a value is specified for the first time, this column offers to Choose Macro. Otherwise, it displays a link called Change Macro. See
|
| Editable Occurrence |
In this column, you can define whether each template variable will have an associated input field during deployment, and where these input fields should be located. |
If a variable appears only once in the template code, this option is expressed by a check box. When this check box is selected, the corresponding field in the resulting code becomes editable. If a variable appears in the template code n times, this option is expressed by a drop-down box with the following possible choices:
|
| Move Up / Move Down |
Define the order of variables in a template by moving the variable rows up and down within the table. |
The order of variables specified in the table determines the order in which ReSharper suggests values for variables when the template is applied. |
