ReSharper 2017.3 Help

Organizing Templates

There are several ways to organize code templates:

Using categories

To navigate between code templates in the Templates Explorer window, you can use Template Scopes, which group templates automatically. Additionally, for secondary grouping, you can assign any code template to one or more categories. For example, if you have templates for unit tests, it could be convenient to create a Unit Tests category and assign them to it. Later you can select this category and find all your unit test templates. Some of the predefined code templates are already assigned to categories (e.g. Iteration).

Templates scopes and categories

As categories work for secondary grouping, you only see templates that match both the selected scope and category. All is a special category that lists all templates in the selected scope.

To create a new category

  1. In the main menu, choose ReSharper | Tools | 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. Select one or more templates that you want to assign to a new category. Use Ctrl-click for multiple selection. Note that categories work as tags and you need to have at least one template in a category.
  4. Click New Category ThemedIcon NewFolder Screen Gray on the toolbar.
  5. In the Create Category dialog that appears, specify a name for a new category and click OK.

To assign other templates to the newly created category, or to an existing category, just drag-and-drop them there.

Categories work as tags and any template can be assigned to several categories simultaneously, so when you drag-and-drop templates from one category to another, templates are not removed from the original category. To remove templates form a category, drag-and-drop them into the All category. As soon as the last template is removed from a category, the category disappears too.

Deleting Templates

When you delete a user-defined template, it is removed from the settings layer where it was defined. However, when deleting a predefined templates, ReSharper just records the deletion of this template in a specific settings layer, so that you could recover predefined templates by clearing this layer. The deleted predefined template will not be available as long as the layer where the deletion is recorded, is loaded in ReSharper. For more information, see Storage of Templates.

If you want to record the deletion of a predefined template in a specific layer, before you delete it, choose this layer in the Layer selector, click Filter Templates ThemedIcon Filter Screen Gray and choose Show predefined templates.

To delete a code template

  1. In the main menu, choose ReSharper | Tools | 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. If you need to delete a template from a particular settings layer, choose this layer in the Layer selector.
  4. In the Scopes area, click the scope that corresponds to the target template. You can also use categories to locate it.
  5. Find a template or templates to be removed and select them. Use Ctrl-click for multiple selection.
  6. Click Delete ThemedIcon Remove Screen Gray on the toolbar.

Disabling templates

All live templates are enabled by default, i.e. you can apply them in your code. If necessary, you can temporarily disable some templates so that they are not appear in the list of suggested templates when you are applying a live template.

To disable or enable live templates

  1. In the main menu, choose ReSharper | Tools | Templates Explorer….
  2. Click on the Live Templates tab.
  3. If you need to disable or enable templates from a particular settings layer, choose this layer in the Layer drop-down list.
  4. Find templates to be enabled or disabled and use check boxes next to template names to toggle their state.
Last modified: 16 April 2018

See Also