Code Snippets in IntelliJ

Code snippets can be helpful. Otherwise the can lead to code duplicates – so use them with wisely.

In JetBrains IntelliJ the code snipptes are called Live Templates. They are stored in files saved in C:\Users\{UserName}\.IntelliJIdea{Version}\config\templates on Windows and ~/.IntelliJIdea{Version}/config/templates on Linux.


To create a live template open IntelliJ and open the Settings from the File menu:


In the Settings dialog you can use the search text box to quickly access the Live Templates section:


Now just select the Language and use the green plus button on the upper right to add a new one (like the iife that I just added here).

There is a special placeholders that can be used aside from variables:


The Edit variables button switches to enabled state as soon as you user a variable name in the code.

Add comment