ReSharper 8.0 Web Help

All templates that you can find in the Templates Explorer can be edited according to your needs and development practices. You can edit template body, change shortcuts for live templates and descriptions for all templates, change template scope, introduce or modify template parameters.

Note

Before editing code templates, it is recommended to study the way ReSharper stores them. Not only different templates can be saved in different settings layers, but modifications to a template can be saved separately in another settings layer.

In most cases, you do not have to do anything about it; just leave the default Smart option in teh Layer selector. But there are cases when you have to select a particular settings layer. Some of these cases are described below.

For more information, see Storage of Templates.

If you are going to edit a template that is shared via the Solution team-shared settings layer or via other shared layer, there are two ways to do so:

  • If you want your changes to affect those who use the same settings layer, make sure to choose the layer where the template is defined in the Layer selector before you start editing.
  • To change the template for yourself and leave the shared version intact, choose Smart (which is the default option) in the Layer selector before you start editing.

If you intend to edit a predefined template, you can also use the distributed storage of templates to your advantage:

  • By default, the Smart layer is chosen in the Layer selector, so your changes will be saved into the This computer settings layer and the modified template will be available in all solutions on your computer.
  • It might be useful to record the changes to the predefined template in a particular settings layer, for instance in the Solution-personal layer, so that the modified version of the template only appears in this solution. To do so, choose the target layer in the Layer selector, click Filter Templates toolbar__filter_usages and choose Show predefined templates and then choose a predefined template that you want to edit.
To edit an existing template
  1. On the main menu, choose ReSharper | Templates Explorer.
  2. In the Templates Explorer window that appears, click one of the tabs to choose the type of the template: Live Templates, Surround Templates, or File Templates.
  3. Optionally, to display and edit templates from a particular settings layer, choose this layer in the Layer selector.

    Warning

    If you intend to edit a user-defined template in the 'Solution team-shared' or any other shared settings layer so that your modifications are saved in the same layer, check that the Layer selector is switched from 'Smart' to the target layer. Otherwise, your modifications will be saved separately in the 'Solution-personal' layer. For more information, see Storage of Templates.

  4. In the Scopes area, click the scope that corresponds to the target template. You can also use categories to locate it.
  5. Find the desired template in the right part of the Templates Explorer and click Edit iconEditTemplate on the toolbar or double-click the template.
  6. When the template opens in the Template Editor, modify it as described in the Creating a Template section.