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.
- 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 a 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.