IntelliJ : Live Templates
A short guide to IntelliJ live templates, the ones I use every day, and a settings file you can import.
One of the most underutilised tools by a developer is their Integrated Development Environment (IDE). The two main common IDEs in use for professional Java development are Eclipse and IntelliJ; the latter being my preferred choice. There are many different features and functionalities that an IDE provides to help the developer produce higher quality code in an efficient manner. In my opinion, one of the features not used enough is Live Templating (IntelliJ) or Templates (Eclipse). I thought I would write a short blog to document and highlight a few templates I have set up in my IntelliJ that are invaluable to my development experience.
With the release of IntelliJ 2018.2, JetBrains have improved their documentation around Live Templates and how to create them. There are three types of live templates:
- Simple Templates
- Parameterised Templates
- Surround Templates
I shall provide examples of the first two as these are the most commonly used and a visual guide on how to set up your own.
Simple Templates
This is used when there are no dynamic variables to change – the code is static. As an example, IntelliJ has pre-setup the abbreviation sout, which expands to:
System.out.println();
An additional template that I have set up is main:
public static void main(String[] args){
$END$
}
$END$ marks where the cursor lands once the template has expanded.

Parameterised Templates
This is used when there are variables that require the user input. The IDE has been programmed to try and calculate these automatically. As an example, IntelliJ has set up fori:
for (int i = 0; i < ; i++) { }
Additional templates to the above that I have set up are logger:
public static final org.slf4j.Logger LOGGER = org.slf4j.LoggerFactory.getLogger($CLASS_NAME$.class)
and test:
@org.junit.Test
public void $NAME$()
{
$END$
}
$CLASS_NAME$ is filled in automatically from the surrounding class; $NAME$ is a variable you type when the template expands.



To save having to set up the above custom live templates, which can be a tedious task, I have attached here a copy of my live template settings to be imported into your local version of IntelliJ. I might add to this list over time so it is worth checking periodically for updates.
Importing Settings
Upon download, please change the file extension to .jar (from .zip) before proceeding with the below steps, taken directly from the JetBrains documentation:
- On the File menu, click Import Settings.
- Specify the path to the JAR file with the exported live template configuration.
- In the Import Settings dialog box, select the Live templates check box and click OK.
- After restarting IntelliJ IDEA, you will see the imported live templates on the Live Templates page of the Settings / Preferences Dialog.
Attachments
- LNLiveTemplatesIntelliJ.zip (1 kB)