IntelliJ IDEA Console Log Options
2020-12-18A common need is to write console.log(`${VAR}`)
statements while coding JavaScript/TypeScript. Ideally one could highlight the variable and use a shortcut. I went searching for a quick method to do this on IntelliJ IDEA. There is a built-in postfix code completion and live templates. It took me a while to find the details.
Relevant question/answers on SO: https://stackoverflow.com/a/52429534/123378
Using Built-in Postfix code completion
// example1
my_var.log + <Tab> => console.log(my_var);
// example2: string
'hello'.log + <Tab> => console.log('hello');
// example3: string and variable
'hello', my_var.log + <Tab> => console.log('hello', my_var);
Custom Live Template
Added ll
trigger with:
console.log($SELECTION$, '$SELECTION$')$END$
Custom Postfix
Replaced existing $EXPR$.log
(log):
console.log($EXPR$)
with
console.log('$EXPR$', $EXPR$)
IntelliJ IDEA Docs
Additional Research
-
Plugin: Super Console Log (Source)
- Doesn’t show up in plugin marketplace.
-
Plugin: Console Log ()Source)
- Reviews indicate only partially works
-
Visual Code Plugin: Turbo Console Log
-
Live Templates