Search code examples
laravelintellij-idealive-templates

PHPStorm / IntelliJ IDEA Live Template string "$" concatenation


Does anyone know how to prefix a "$" next to a $STRING$ entry? $$STRING$ seems to remove the ability for the template system to recognise this as an input variable.

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$ . "suffix"

Both of these would be very useful!!

Cheers


Solution

  • Short answer: Just use $$ (therefore $$$STRING$).


    To clarify the OP's problem with an example:

    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 :) ).

    So if you used the n macro and typed Person, the output would be $person = new Person();

    And since you want to autocomplete the $person variable based on Person class, you need to have $<variable> = new <Class>();, which translates to $$$VAR$ = new $CLASS$(); $END$ in PhpStorm.


    For anyone interested in the full n live template:

    The full template in PhpStorm


    My answer is indirectly based on this answer.