How to capitalize the second appearance of the same variable in WebStorm?

205 Views Asked by At

I have the following WebStorm Live Template:

[$VAR1$, set$VAR1$]

My goal is to capitalize the second occurrence of $VAR1$.

e.g. for the input: foo
the output should be: [foo, setFoo]
right now the output is: [foo, setfoo]

For Live Templates, there is a Dialog where I can define a function expression to capitalize a variable:
enter image description here

The problem here is that the definition is per variable, so both occurrences are capitalized then.

How can I capitalize only the second occurrence, or copy the value of one variable into another one which would be capitalized then?

1

There are 1 best solutions below

0
lena On BEST ANSWER

Just add another variable:

$VAR1$, set$VAR2$

enter image description here

See https://blog.jetbrains.com/webstorm/2022/02/creating-and-using-code-snippets-with-placeholders/, you may find this blog post useful