With ReSharper, you can create live templates based on a fragment of your source code. In so doing, ReSharper suggests variables to be used as input fields when the template is applied. The new template is stored in ReSharper | Live Templates | Live Templates | User Templates.
- In the editor, select a block of code to create a template from.
- On the main menu, choose ReSharper | Tools | Create Live Template from Selection.
In the Select Fields and Context for New Template dialog box,
ReSharper suggests a draft for the new template, along with optional list of
- If the Template Variables section contains entries, deselect variables that you think ReSharper shouldn't use as input fields. As you select or deselect variables, the Template Text section changes accordingly.
- In the Context drop-down list, select the context where the new template is applicable.
- Click Create and Edit.
- In the Template Editor code pane, enter template shortcut,
optional description, and specify formatting options. Modify template text if necessary.
Creating a Templatefor details.
- In the list of template variables to the right of the text area, choose macros for variables,
or create them from scratch
if ReSharper failed to guess them from selection. See
Declaring Variablesfor details.
- On the main menu, choose File | Save Selected Items, and close the Template Editor code pane.