Managing and Sharing Live Templates

You can manage Live Templates in the following ways:

Live Templates Dialog

Management of Live Templates is performed via the Options - Live Templates dialog. To open it, select ReSharper | Options from the main menu and in the left pane click Live Templates.

Available Templates

The structured view presents all available Live Templates with their abbreviations and brief descriptions. Available templates and folders containing them are organized in four sections explained below:

The checkbox to the left of each template is used to indicate current template availability. Clear the checkbox of a template to make it unavailable and be excluded from popup-lists of Live Templates.

Preview

When a template is selected in Available Templates, its definition (template code) appears in this text field. To modify the code of a template, double-click the template in Available Templates or use the toolbar (see below).

Toolbar

The toolbar is located above Available Templates. It lets you create, edit, move, delete, export and import templates and share them with members of your development team. The following table explains the purpose of each button:

Button

Name

Description

Create Template

Creates a new template. See Organizing Live Templates.

Create Folder

Creates a new template folder. See Organizing Live Templates.

Copy Template or Folder

Creates a copy of the currently selected template or folder in the specified location. See Organizing Live Templates.

Delete

Deletes the selected template or folder (confirmation is requested). See Organizing Live Templates.

Edit Template

Opens the Edit Template dialog for editing the selected template.

Move Template or Folder

Moves the selected template or folder. See Organizing Live Templates.

Import Templates from File

Imports template(s) from an XML file containing Live Templates. See Importing and Exporting Live Templates.

Export Templates from File

Exports template(s) to an XML file. See Importing and Exporting Live Templates.

Mount File Storage Mounts file storage from a file that contains Live Templates designed for common use among a group of developers. See Sharing Live Templates.

Organizing Live Templates

 

To create a new template:

  1. Click  (Create Template). The Choose Destination Folder dialog is displayed:

  2. Do one of the following:
    • Select an existing folder for the new template and click OK.
    • Create a new folder for the new template: click  and specify the new folder name. Then select the folder and click OK.
  3. Specify the new template's details via the Edit Template dialog. Please refer to Editing Code Templates for details.

To create a new template folder:

  1. Click  (Create Folder). The Choose Destination Folder dialog is displayed.
  2. Choose the new folder's location using the dialog and click OK.

To create a copy of a template or folder:

  1. Select a template or folder.
  2. Click  (Copy Template or Folder). The Choose Destination Folder dialog is displayed.
  3. Select the destination folder for the new template or folder and click OK.

OR

Note   Templates with identical names will conflict with each other. If you've copied a template, modify its name and/or template code to avoid ambiguity and possible errors.

To delete a template or folder:

  1. Select the template or folder and click  (Delete).
  2. Confirm deletion.
Note Predefined templates and the four main folders cannot be deleted.

 

To edit a Live Template:

  1. Select the template.
  2. Click  (Edit Template) or double-click the template.
  3. Modify template details via the Edit Template dialog.
Tip   It is recommended that you don't modify predefined templates since any changes may be lost if you later re-install ReSharper. Instead, make a copy of the template and edit it.

To move a template or folder:

  1. Select a template or folder.
  2. Click  (Move Template or Folder). The Choose Destination Folder dialog is displayed.
  3. Select the destination folder for the new template or folder and click OK.

OR

  1. Drag the template or folder to the destination folder.
Note    Predefined templates and the four main folders cannot be moved (but predefined templates can be copied).

Importing and Exporting Live Templates

Live Templates can be exported to an XML file. This allows you to save your customized templates so that you can distribute them, share with other developers, temporarily save them between re-installations of ReSharper, and so on. Once exported (by you or someone else), Live Templates can be imported.

To export templates:

  1. Click  (Export Templates to File). The following dialog is displayed:

  2. Select the checkboxes of the templates you would like to export. Optionally, select a folder to include all of the templates it contains.
  3. Specify the file to export to, using the browse button if necessary. Click OK.

To import templates:

  1. Select the destination folder for importing templates, other than Predefined Templates.
  2. Click  (Import Templates from File). The Choose File with Templates dialog is displayed.
  3. Specify the file from which to import templates. The templates file must have been created with ReSharper for the import to work correctly.
  4. Click OK.

Sharing Live Templates

Live Templates can be shared in two ways.

Shared Solution Templates folder

You and other members of your development team can use this folder to store shared templates designed for use with any particular solution. Templates placed in the folder will be accessible to anyone who opens the current solution. Compare with Personal Solution Templates folder: templates it contains are available for your personal use with a particular solution, but not to others.

Mounted File Storage

Live Templates can be shared among a group of developers via Mounted File Storage. First, all members of a development team mount file storage. The file contains templates designed for common use by a group of developers. It is stored on a shared network location accessible to each developer. Templates contained in the mounted file are updated from and to the file with every opening and closing of the solution. Any changes made to the file are automatically made available to all other developers.

To mount file storage:

  1. Click  (Mount File Storage). The Choose File with Templates dialog is displayed.
  2. Specify the file from which to import templates. The templates file must have been created with ReSharper for the import to work correctly.
  3. Click OK.

See Also

Editing Templates | Using Live Templates | Predefined Live Templates