Member-only story
IntelliJ Live Template for console.log That Will Improve Your Daily Development Life
Out of free stories? Get this article for free at https://aiko.dev/intellij-live-template-for-console-log/
A handy shortcut for one of our most common tasks

(An updated version of this post can be found here)
We’ve all been there. Our code is not behaving like we hoped it would and it’s not obvious why. The easiest and fastest way to get a clue for what’s going on is to simply put a print statement in the code. It’s not nice; we should use a proper debugger, but we do it anyway.
The following live template will add the console.log(‘’) statement to your code; automatically insert the class name, function name, and line number in the log message; offer code completion for the message you want to log; and place the cursor where you need it.
According to Larry Wall, the original author of the Perl programming language, one of the three great virtues of a programmer is laziness.
So let’s automate the boring stuff!
There’s a video showing the setup and usage of the live template further down. You can pause and skip parts of the video or just follow the instructions below.
Steps to Follow
Live template preferences:
- Go to Preferences( ⌘ + , ).
- Select Editor/Live Templates (you can type live templates to find it).
- Select Javascript.
- Press the ‘+’ sign at the top right corner of the window( ⌘ + N ).
- Select Live Template (press 1 or Enter).
Edit template:
- Enter the abbreviation you want to assign to the template. We will use cl in this case.
- Enter the description for the template (e.g. “inserts console.log(‘’);” ).
- Paste the following template code:
console.log('Class: $CLASS$, Function: $FUNCTION$, Line $LINE$ $PARAM_TEXT$($EXPECTED$): '
, $PARAM$);$END$
- Click Define below the template text field and…