ReSharper Web Help

To create a code template from scratch
  1. On the main menu, choose ReSharper | Live Templates. The Templates Explorer window displays:
    Templates Explorer tool window
  2. Select one of three tabs corresponding to the required type of template: Live Templates, Surround Templates, or File Templates.
  3. Select a target category (User Templates, Personal Solution Templates, or Shared Solution Templates), and click (New Template). Template Editor appears in a new Visual Studio code pane:
  4. Identify your new template in one of the following ways:
    • For a live template, specify a shortcut (abbreviation) in the Shortcut field. A template shortcut is used to quickly invoke the corresponding template from the code editor. In the Description field, type optional description for the template.
    • For a file template, fill in two text fields: Description (name of template) and Default file name (the file name that ReSharper suggests by default when a user invokes this particular template). Optionally, select File name must be a valid identifier to make ReSharper validate file name in the Create: [name of template] when you apply the template.
    • For a surround template, specify the name of a new template in the Description field.
  5. To specify the availability context for the template, click the Available hyperlink. When the Template Availability dialog box appears, use radio buttons and check boxes to define where the new template can be applied.
  6. In the text area provided by the Template Editor, enter the template source code that may contain plain text and optional variables. Template variables (for example, $var$) appear in the list to the right of the text area as you type them. See Template Variables for details on template variables.
  7. Specify marcos for the variables. For guidelines, see Declaring Variables.
  8. Configure template formatting options:
    • Select Reformat to make ReSharper automatically reformat the expanded code fragment according to your code style settings.
    • Select Shorten qualified references to make 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 won't insert any namespace import directives at all.

See Also

Procedures

Reference