Code Templates

Live Templates

Live templates are ReSharper's far more intelligent version of Visual Studio's code snippets.

To apply a live template, just type a template abbreviation, and press Tab in the completion list to expand the template. After that, use Enter or Tab to navigate through template parameters. (If you use Visual Studio's native code completion, press Ctrl+J to display the list of available live templates to expand a template.)

Unlike code snippets, ReSharper can predict from the context which variables, fields, and types can be used in corresponding templates. In most cases you don't need to type anything yourself. Just choose from a list of suggested values.

ReSharper provides 30 predefined live templates for C#, more than 20 live templates for VB.NET; there are predefined live templates for ASP.NET, XML, HTML, JavaScript, Razor, and Resx files. The list includes templates for iterating through collections, writing assertion methods, creating new arrays, outputting values, coding LINQ queries and generating auto-properties, and more.

'Surround With' Templates

'Surround with' templates are used to quickly enclose an expression, a single statement, or an arbitrary block of code with if/else, try/catch or other code constructs. ReSharper intelligently reformats the code, adjusts the selection, and/or repositions the caret as specified by the template.

To surround a piece of code, select it and press Ctrl+Alt+J.

File Templates

ReSharper lets you add new files to your project with predefined code fragments already generated in them. For example, you can create a new file with a class declaration, an interface, struct declaration, and so on. To choose from the list of file templates, press Ctrl+Alt+Ins without even leaving the text editor.

Customizing, Configuring and Sharing Templates

You can create your own templates and modify those that come bundled with ReSharper.
For editing templates, ReSharper provides Template Editor that opens in a separate Visual Studio code pane, allowing you to switch between your code and your template editing environment to make real-world testing of templates faster.

For managing templates, you can use Templates Explorer that you can call by choosing Live Templates on the ReSharper menu:

Once defined, any template can be easily shared among team members in two ways using the Templates Explorer.

Importing and Exporting Templates

You can export code templates to a file and distribute or share it with other developers. Accordingly, you can import code templates created and shared by other developers.

Sharing Templates

Another way of sharing templates with your team members is using the mechanism of settings layers as code templates are saved in ReSharper settings. To make templates available to other developers who work on the same shared solution, you can either create new code templates in a team-shared settings layer or copy existing templates to a team-shared settings layer.


All keyboard shortcuts provided in the "Features" section are taken from ReSharper 2.x / IDEA keyboard scheme. For details on ReSharper's two default keymaps, see Documentation and Demos.