简体   繁体   English

PHPStorm / IntelliJ IDEA动态模板字符串“ $”的连接

[英]PHPStorm / IntelliJ IDEA Live Template string “$” concatenation

Does anyone know how to prefix a "$" next to a $STRING$ entry? 有谁知道如何在$ STRING $条目旁边添加“ $”前缀? $$STRING$ seems to remove the ability for the template system to recognise this as an input variable. $$ STRING $似乎消除了模板系统将其识别为输入变量的能力。

While we are on the topic, is it possible to concatenate/edit a previously declared variable in the variable editor? 当我们讨论主题时,是否可以在变量编辑器中连接/编辑先前声明的变量? So setting: 因此设置:

$STRING$'s default to: $VAR$ . $ STRING $的默认值为:$ VAR $。 "suffix" “后缀”

Both of these would be very useful!! 这两个都是非常有用的!

Cheers 干杯

Short answer: Just use $$ (therefore $$$STRING$ ). 简短的答案:只需使用$$ (因此使用$$$STRING$ )。


To clarify the OP's problem with an example: 为了举例说明OP的问题:

Imagine that you wanted to have an n live template (macro) that creates a new instance of a class and stores it in a variable of the same name (Netbeans users will know :) ). 想象一下,您想要一个n模板(宏),该模板创建一个类的新实例并将其存储在同名的变量中(Netbeans用户会知道:))。

So if you used the n macro and typed Person , the output would be $person = new Person(); 因此,如果使用n宏并键入Person ,则输出将为$person = new Person();

And since you want to autocomplete the $person variable based on Person class, you need to have $<variable> = new <Class>(); 并且由于要基于Person类自动完成$person变量,因此需要$<variable> = new <Class>(); , which translates to $$$VAR$ = new $CLASS$(); $END$ ,表示为$$$VAR$ = new $CLASS$(); $END$ $$$VAR$ = new $CLASS$(); $END$ in PhpStorm. PhpStorm中的$$$VAR$ = new $CLASS$(); $END$


For anyone interested in the full n live template: 对于对完整的n实时模板感兴趣的任何人:

PhpStorm中的完整模板


My answer is indirectly based on this answer . 我的答案间接基于此答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM