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

前端 未结 1 675
日久生厌
日久生厌 2020-12-11 05:19

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(\'$T         


        
相关标签:
1条回答
  • 2020-12-11 05:53

    You cannot do that for the same variable as each variable is processed only once.

    Solution: create another/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.

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

    Related StackOverflow question: https://stackoverflow.com/a/40606436/783119

    0 讨论(0)
提交回复
热议问题