ReSharper Web Help

A code template may contain:

  • Plain text that represents source code constructs and comments. It is inserted without changes when the template is applied.
  • Variables that may be converted into fields when the template is applied. A template variable has the following format:
    $VARIABLE_NAME$ - where variable_name represents an arbitrary identifier.
    When the format is correct, Templates Explorer highlights predefined variables in dark blue and other variables in dark red:

Predefined template variables

The following template variables are predefined in ReSharper:

  • $END$: Denotes the final caret position after the template is applied and the user exits the template editing mode.
  • $SELECTION$: Denotes the text selected by the user before they invoke the template. This variable is only used with surround templates.
  • $SELSTART$: Denotes the starting position of the text block that will be selected after the template is applied.
  • $SELEND$: Denotes the ending position of the text block that will be selected after the template is applied.


If neither $END$ nor $SELSTART$ and $SELEND$ variables are used in a template, the caret position is set after the last symbol of the template. If you use $SELSTART$ and $SELEND$ variables together with $END$ variable, the latter will be overridden. Before creating new custom templates, you can study the predefined ReSharper templates to learn how to use variables.

Other template variables

All other variables are declared explicitly when you create or edit a template. You can supply your variables with predefined values and/or with macro-rules for calculating them.

Also, you can define an interactive behavior for variables so that a variable become a template parameter. For more information, see Parameterized Templates

See Also