ReSharper Web Help

ReSharper supports three types of code templates:

  • Live templates represent code fragments that can be quickly inserted into your code. The code of the template can be a short expression, a complete construct, or even an entire class or method. Each live template is identified by a Shortcut - a short string of characters such as itar (abbreviation of "Iterate an array"),  thr (for "throw new") - that you can type right in the editor to invoke the template. For more information, see Creating Source Code Using Live Templates.
  • Surround templates let you quickly enclose an expression, a single statement or an arbitrary block of code with a predefined code construction, such as for loop, or try...catch statement. Surround templates have no shortcuts, they are identified by their descriptions. See Surrounding Code Fragments with Templates for details.
  • File templates are used to create one or more new files with predefined code, such as a class or interface declaration, unit test, ASP.NET page with code behind file, etc. File templates have no shortcuts, they are identified by their descriptions. See Creating Files from Templates and Creating and Editing Multi-File Templates for details.

Right after installing ReSHarper, you will find a lot of predefined templates of all three types. Predefined templates cover the most common cases for C#, VB.NET, ASP.NET, XML, HTML, Razor, CSS, JavaScript, and Resx code. ReSharper also imports Visual Studio code snippets for C# and JavaScript and adds them to the list of predefined templates.

For custom cases, ReSharper provides tools for creating, editing, and sharing user-defined code templates that can cover any particular aspect of your development practices.

Tip

To understand how ReSharper stores templates, see Storage of Templates.


This feature is supported in the following languages/technologies:

C# VB.NET HTML ASPX Razor JavaScript TypeScript CSS XML XAML RESX Build Scripts
feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available

Tip

The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see the corresponding topics in the ReSharper by Language section.