IntelliJ Live Templates
Create and use live templates in IntelliJ IDEA
Accessing Templates
Ctrl+Alt+S / Cmd+, # open settings
Editor > Live Templates
# Use template
Type abbreviation + Tab
# Surround with template
Ctrl+Alt+T / Cmd+Opt+T
Creating Templates
# New template
Abbreviation: psvm # trigger
Description: main method
Template text:
public static void main(String[] args) {
END
}
Define context: Java > Declaration
Template Variables
VAR # editable variable
END # final cursor position
SELECTION # selected text
CLASS_NAME # current class name
METHOD_NAME # current method
DATE # current date
USER # username
Predefined Functions
className() # current class name
methodName() # current method
date() # current date
time() # current time
user() # system username
capitalize(String) # uppercase first
camelCase(String) # to camelCase
Example Templates
# System.out.println
sout → System.out.println(END);
# For loop
fori → for (int i = 0; i < LIMIT; i++) {
# TODO comment
todo → // TODO: DATE USER - END