Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebStorm - Live templates - indicate the order of focusing the same variable

I am interested in if there is a mean to indicate where the writing the variable name should start

e.g if I call this live template:

console.log('$TEXT$', $TEXT$);
             ^

It will start writing from the first TEXT variable.

I want to start writing from the second one:

console.log('$TEXT$', $TEXT$);
                      ^
like image 803
Shota Avatar asked Jan 13 '17 09:01

Shota


1 Answers

Indicate the order of focusing the same variable

You cannot do that: each variable is processed only once.

The solution is to apply a simple workaround: create an additional/intermediate variable that will automatically get the same value from the first variable and arrange them in the desired order.

  1. Create a new variable and give it different name (e.g. $VAR$):

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

    NOTE: I've also added $END$ to denote final cursor position

  2. Click on the Edit variables button.

  3. Rearrange variables in desired order (using Up / Down buttons on the right side).

  4. Assign default value for TEXT variable: make it to accept the value that you will enter for VAR variable.

  5. Also check the Skip if defined checkbox if you do not plan to edit the TEXT value while filling the variables.

enter image description here

Result: only 1 place to enter variable name (code completion is available if needed) and the entered value is automatically copied into the text field (which you can still edit later once you're done with expanding the template).

enter image description here

Related StackOverflow questions:

  • WebStorm - Live templates - indicate the order of focusing the same variable
  • WebStorm JavaScript live template - deciding where the cursor will be
like image 108
LazyOne Avatar answered Sep 24 '22 08:09

LazyOne