Live template variables
When you expand a live template abbreviation, its variables either appear as input fields where you can type values or are replaced with values. These may be default values that you can modify or values calculated using functions.
To declare variables within templates, use the following format: $VAR$
.
Define each variable using an expression and provide a default value for cases when the expression fails to evaluate.
Configure template variables
In the Settings dialog (Ctrl+Alt+S) , go to .
Select a template where you want to configure variables (for example, Rust) .
Specify variables in the following format:
$VARIABLE_NAME$
. If a template contains any variables, the Edit Variables button is available. Click this button to set variable values.In the Edit Template Variables dialog, you can do the following for each variable:
Change the variable name.
Define an expression.
This expression may contain the following constructs:
String constants in double quotes
Names of other variables defined in a live template
Predefined functions with possible arguments
Specify the default value for cases when the expression fails to evaluate. The default value should be enclosed in double quotation marks.
Specify whether you want to skip the variable when prompting the user for input if the expression evaluated successfully.
Predefined template variables
RustRover supports the following predefined live template variables that cannot be modified:
$END$
indicates the position of the caret when the code snippet is complete, and you can no longer press Tab to jump to the next variable.$SELECTION$
is used in surround templates and denotes the code fragment to be wrapped. After the template expands, it wraps the selected text as specified in the template. For example, if you selectEXAMPLE
in your code and invoke the"$SELECTION$"
template via the assigned abbreviation or by pressing Ctrl+Alt+T and selecting the desired template from the list, RustRover will wrap the selection in double quotes as follows:"EXAMPLE"
.