ReSharper Web Help

ReSharper defines a number of scopes where a code template is available. They help you limit usage of a particular code template to relevant scopes. Scopes apply to all types of templates (Live Templates, Surround Templates, File Templates).

For example, the predefined live template itar (iterate an array) is available by default in C# 2.0 + where expression is allowed. It means that this particular scope is defined for this template; you can apply the itar template in the body of a C# method, but you cannot apply it in the body of a C# class outside of any members or, say, in an XML file.

Each code template can be assigned to several scopes. Template scopes are displayed in the Available hyperlink when you open a template in the Template Editor:

You can edit the template scopes in the Select Scopes dialog box that opens by clicking on the Available 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.
  • 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.

Template scopes are also used to visually group templates in the Templates Explorer 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.

See Also

Concepts

Procedures

Reference