ReSharper defines a number of scopes where a code template can be available. Scopes help you limit usage of a particular code template to the relevant context.
For example, the predefined live template itar (iterate an array) is available by default in C# 2.0+ statements. It means that this particular scope is defined for this template; you can apply the itar template in the body of a C# statement, but you cannot apply it in the body of a C# class outside of any members or, say, in an XML file.
In the Templates Explorer window, where you start exploring and managing templates, template scopes are also used to visually group templates and help you navigate between them. Live templates and surround templates are grouped by file type; file templates are grouped by project type. Templates with special scopes fall into the Global group.
You can assign several scopes for each template. All template's scopes are shown in the Availability hyperlink when you open a template in the Template Editor:
You can edit template scopes in the Select Scopes dialog that opens by clicking the Availability hyperlink. For detailed instructions, follow the Creating a Template or Editing a Template procedures.
The scopes for live templates and surround templates are defined by file type and allowed location. The scopes for file templates are defined by project type. Also, there are special scopes:
- Everywhere - can be assigned to all types of code templates. Templates with this scope apply everywhere.
- Nowhere - can be assigned to all types of code templates. You cannot apply templates of this scope. However, you can use this scope for drafts of your new templates so that they do not appear in menus and completion lists.
- In files matching [file mask] - can be assigned to live templates and surround templates. Templates with this scope apply in all files that match the specified file mask. When you assign this scope to a template, you can specify one ore more file masks.
- Any project - can be assigned to file templates. Templates with this scope apply in any project.