如何在Intellij IDEA中设置实时模板中变量的默认值? [英] How to set default value of variable in live template in Intellij IDEA?

查看:934
本文介绍了如何在Intellij IDEA中设置实时模板中变量的默认值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Intellij IDEA中的实时模板可能会有一些误解。我的意思是模板中变量的默认值。

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


我在此期望,在调用此模板时(键入 jqon 并按 TAB )我会看到已输入的默认值,我可以更改或保留原样。喜欢这个

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

为什么?

推荐答案

我错了默认值字段。在我的情况下,我不需要这个。我需要填写 Expression 字段。

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

如果我只想粘贴一些字符串作为默认值,我应该将此字符串放在 Expression 中的引号中。所以现在我的变量设置看起来就像这样

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!

这篇关于如何在Intellij IDEA中设置实时模板中变量的默认值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆