Repeated Java statements often differ by a single value. In IntelliJ IDEA on Linux, a live template lets you insert a statement by typing a short abbreviation, then fill in the part that changes.
A template's context controls where the IDE offers it. A Java statement template fits inside a method body, where Java accepts statements.
IntelliJ IDEA and PyCharm both keep template settings under Editor > Live Templates. Each template can have its own expansion key, so you can choose Tab for one abbreviation regardless of the default key.
Steps to create a live template in JetBrains IDE:
Start with a Java file open and the caret on an indented blank line inside a method. The example uses the main method in src/Main.java in the ~/IdeaProjects/hello project.
- Press
Ctrl+Alt+Sto open Settings.
- Click the search box in the upper-left corner of Settings.

- Enter
Live Templatesin the Settings search box.
- Select Live Templates under Editor in the search results.

- Click the × at the right end of the search box to clear the search highlight.

- Click + above the template list to open the add menu.

- Select Live Template from the add menu.

- Replace the selected text in Abbreviation with an unused abbreviation such as
jstatus.
- Click inside the Template text field.

- Enter the Java statement with its placeholders in Template text.
System.out.println("Status: $MESSAGE$");$END$
During expansion,$MESSAGE$is where you type.$END$sets where the caret lands when you leave the placeholder. - Click Define below Template text to open the context chooser.

- Expand Java in the context chooser using the arrow beside its checkbox.

- Select the Statement checkbox under Java.

- Press
Escto close the context chooser.
- Open the template's Expand with list under Options.

- Select Tab as the expansion key.

- Click OK to save the template.

- Type your abbreviation on the blank line inside the method, using
jstatusfor the example.
- Press
Tabwith the caret immediately after the abbreviation to expand it.
The Download Full Line Code Completion model notice shown here may appear as you type. The download is optional and you can expand the template with
Tabwhile the notice is visible. - Type a message such as
readyinto the active placeholder inside the quotes.
- Press
Tabto finish editing the placeholder.
- Check that the expanded statement contains your message inside the quotes where the abbreviation was.
The example line reads
System.out.println("Status: ready");.