Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
476 views
in Technique[技术] by (71.8m points)

jetbrains ide - 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$);
                      ^
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

Solution: create an additional/intermediate variable that will automatically receive the same value and arrange them in desired order.

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

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

    (I've also added $END$ to denote final cursor position)

  2. Click on 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 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 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 question: https://stackoverflow.com/a/40606436/783119


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...