0

I have this snippet that are used in textmate:

var ${0:name} = ${1:"${2:value}"};

When this snippet get called, first the name will be selected and I have a chance to type something and change the variable name. Press TAB again it will select "value", in this case if my value is a number (the quotes is not required) I can start to type a number and overwrite "name". If my value is a string, I can press TAB again and it will select name (no quotes), I can actually type something and they will appear in the quotes. I want to know if this is doable in JetBrains software like Intellij IDEA and AppCode. I've tried but failed. Below is my code for JetBrains software.

var $name$ = "$value$";

I don't know how to give me a chance to select "value" instead of directly selecting value. Anyone can point me to the right direction? Thanks.

Just a learner
  • 26,690
  • 50
  • 155
  • 234

1 Answers1

0

I don't think you can do exactly what you want. I got fairly close using this template:

var $name$ = $QUOTE$ $value$ $QUOTE$;

Then in "Edit variables" I set the expression for QUOTE to be "\"" and moved value above QUOTE.

This allows you to type the name, as you wanted, and tab next to value, where you can enter a string or a number. The next tab will highlight the first quote, which you can delete if you had a number - this will also delete the trailing quote.

However this is not exactly what you wanted, as the value inside the quotes, should you leave them there, has spaces either side. This is because what I really wanted was

var $name$ = $QUOTE$$value$$QUOTE$;

but if you put two variables next to each other like this, IntelliJ gets very confused.

I know this isn't the answer, but maybe it has you thinking about slightly different approaches to the problem.

Trisha
  • 3,891
  • 1
  • 25
  • 39