ReSharper Web Help

There are several ways to organize code templates:

Using categories

To navigate between code templates in the Templates Explorer, 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. 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. 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 iconCreateCategory on the toolbar.
  5. In the Create Category dialog box 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.

Note

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 toolbar__filter_usages and choose Show predefined templates .

To delete a code 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. 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 toolbar__remove 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.

Note

If you disable predefined live templates, their disabled state is recorded in a specific settings layer the same way as deletion.

To disable or enable live templates
  1. On the main menu, choose ReSharper | 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.