R@ndom Curve

IntelliJ Live Templates
Andres C. Rodriguez 2015-07-31

How to add and maintain a list of Live Templates (code snippets) on top of IntelliJ.


I (not so) recently switched from Eclipse to IntelliJ. Mainly for Node.js programming, which I keep hearing will get better in Eclipse, but got tired of waiting for (new, modern JS features). So, one thing I noticed is that the code templates that come with IntelliJ are nowhere near the level of the ones that come with eclipse. On the HTML front, Eclipse ships with 15 templates, IntelliJ with 4 (three of them pretty much useless).


So I decided to try to build some nice templates around IntelliJ based on the ones found in Eclipse.


I always keep forgetting how to structure a link and script tag correctly, so I thought I would start by creating templates for those tags. The are relatively straight forward:

<link rel="stylesheet" href="$SELECTION$">


<script type="text/javascript" src="$SELECTION$"></script>

Live Templates Library

IntelliJ is not very “nice” about letting you import and export those templates. A way of doing this is manipulating the XML templates files where the templates are stored. IntelliJ stores the live templates under ~/Library/Preferences/<product name><version number>/templates (at least on OS X). See the Live Templates page for more details.

Here we can store the html_xml.xml file (see below), which contains templates for the tags:

Those are the HTML tags that in my opinion are the most cumbersome to type. In order to make them work better we have to delete the t and T templates that come with IntelliJ so that we are presented with only one option



If you create this xml file and put it in the right location you will get these “essential” templates. Cheers.