Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
491 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 Reply

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...