44

There could be a little misunterstanding in live templates in Intellij IDEA. I mean default values for variables in templates.

Suppose we have this live template

enter image description here enter image description here

What I expect here, that when calling this template (type jqon and press TAB) I will see default values already typed which I can change or leave as it is. Like this

enter image description here

But no. I have empty strings instead of default values

enter image description here

Why?

2 Answers 2

58

I was wrong about Default value field. I don't need this in my case. I need to fill Expression field.

If I want just paste some string as default value I should put this string in quote in Expression. So now my variable settings look this way

enter image description here

And everything works how I want!

6
  • 2
    That is the reply I sent you to the support mail =)
    – CrazyCoder
    Commented Dec 24, 2012 at 6:38
  • 5
    @CrazyCoder what's the use for the "Default value" field then?
    – Flatline
    Commented Mar 21, 2014 at 18:38
  • 2
    @Flatline you can find it in help.
    – CrazyCoder
    Commented Mar 21, 2014 at 18:48
  • 3
    Thanks!. imho this is very bad UX. default value should behave like this Commented Jan 7, 2016 at 9:34
  • 34
    Double quoted string in "Expression" field works as you wanted also but "Default value" field is the right place for that purpose. All you needed were double quotes.
    – RabbitHole
    Commented May 19, 2016 at 4:08
51

If you want a hardcoded string as the default value field (in the edit variables dialog), it needs to be in double quotes ("ii"). Putting a string there with no quotes (ii) does not result in an error, but also does not work.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.