How to set default value of variable in live template in Intellij IDEA?

自古美人都是妖i 提交于 2019-12-05 09:08:50

问题


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

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

But no. I have empty strings instead of default values

Why?


回答1:


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

And everything works how I want!




回答2:


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.



来源:https://stackoverflow.com/questions/14015108/how-to-set-default-value-of-variable-in-live-template-in-intellij-idea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!