I would like to add a new line right after the line where I selected a variable name. This line should than contain the selection.
Example:
var variable = getValue();
I select the word "variable", press CMD+J to apply a live template or CMD+Alt+T to surround the selection with a live template and get something like this:
var value = getValue();
console.log('[value]', value);
This doesn't work exactly as you expect, but the result is the same. Create a new Live Template (Settings → Editor → Live Templates) and add an abbreviation (e.g. logv
). Set the applicable context to Javascript
. Use this as a template:
console.log("$EXPR_COPY$ = " + $EXPR$);
Now click the Edit variables
button and copy this:
The order is important: first EXPR
, then EXPR_COPY
.
Now you can type logv
(the abbreviation you chose) to paste the template. You will have to enter the variable name (using autocompletion), but the variable name will be copied into the string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With