Live template: two occurences of same $var$, start at second one.


So I have a simple live template for console.logging:

console.log('$VAR$', $VAR);

The problem here is that since the first var is a string, auto-completion is disabled, ruining the efficiency gained by using it. Turning it around:

console.log($VAR$, '$VAR');

When turned around, and starting with the real var, it works decent: auto completion is enabled, and I can log fast many items that I need.

But now the problem is that the descriptive string is logged after the logged var, making it hard to read in a browser console window, again losing that wanted efficiency. This is especially problematic if you are logging many items during debug.

Given the template: console.log('$VAR$', $VAR), how can I make the cursor start at the second occurrence of the same var, and thus make auto completion be enabled while typing, while having the exact name of the logged var given as string as first param to the console.log function?


Comment actions Permalink

Not sure if I got your scenario but you may use two variables and change their order in "Edit variables" and the caret will start from the second var:

Does it look like what are you looking for?

Comment actions Permalink

@Igor Willems

Same as @Vasiliy said, just a tiny bit different:

Comment actions Permalink

Oh wow, never would have come to the idea of using two different vars. That still feels counterintuitive, all though I understand why it works.

Nonetheless, this is exactly what I wanted, and logging speed is extremely fast :) Thanks a lot guys.



Please sign in to leave a comment.