Is there any way to use a default token value in Intellij Live templates
? For example I have the following live template which declares a private variable that I would like to create nearly for every class:
private static final Logger logger = Logger.getLogger($CLASS$.class)
It seems unnecessary to type $CLASS$
every time when this live template is used, because it can be derived from the class in scope or filename. I was wondering if it is possible to use environment defined tokens in live templates as defaults?
Use live templates to insert common constructs into your code, such as loops, conditions, various declarations, or print statements. To expand a code snippet, type the corresponding template abbreviation and press Tab . Keep pressing Tab to jump from one variable in the template to the next one.
Press Ctrl+Alt+S to open the IDE settings and select Editor | Live Templates. Select the template group where you want to create a new live template (for example, other). If you do not select a template group, the live template will be added to the user group. and select Live Template.
Live template group configuration files are stored in the templates directory of the IDE configuration directory.
From the main menu, select File | New Projects Setup | Save Project as Template. In the dialog that opens, name the template and configure the options: Save: if the project contains more than one module, select whether you want to create a template from the whole project or from one of the modules.
Check some other templates that already use the current class name:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With