You can define and edit template variables in the Template Editor.
As soon as you type a user-defined variable in the body of a template
(for example, $VAR$),
it appears in the right part of the Template Editor:
Any particular variable may appear in a template more than once.
You cannot edit values of the predefined template variables ($END$, $SELECTION$, $SELSTART$, and $SELEND$).
- Create a new template or open an existing template for editing.
- Enter a variable as $variable_name$ in the text area of the Template Editor.
- To define a value of the variable, find it in the right part of the Template Editor and click Choose Macro. If a macro is already defined, click Change Macro to switch to another macro.
- In the Choose Macro dialog box that appears, select a macro from the list and click OK. If the selected macro does not contain references, proceed to step 6.
- If the selected macro contains parameters, they are displayed in bold (for example, format or type). In this case, a link highlighted in red will appear in the Value column next to the variable. Click the link to specify the parameter value. See Choose Macro for details.
If you want that variable to become a
the Editable Occurrence should be enabled.
Depending on the number of variable occurrences within the template, do one of the following:
- If the variable appears in the template only once, select or deselect the check box.
- If the variable appears in the template more than once, the combo box appears, where you can select a sequential number of the editable occurrence. This number specifies to what occurrence of the variable the input focus will be set when the template is applied.
- Optionally, click Move Up or Move Down to define the order that ReSharper will use to suggest input fields when a parameterized template is applied. This order affects only variables with the enabled occurrence.
- To save changes, choose File | Save Selected Items on the Visual Studio menu or press Ctrl+S.