Search code examples
phpphpstormjetbrains-idelive-templates

PhpStorm live template expression to convert current variable


So we can use expressions to transform other variables in live templates. For example:

Working example with two variables while second one references the first one

Is it possible to apply snakeCase to NAME directly? So whatever I type, gets converted into snake case? Desired result:

Example with expected behaviour, having just one variable

Tried snakeCase(NAME), snakeCase(String) and snakeCase(). None seemed to work. Maybe someone had it figured out?


Solution

  • No, it's not possible - you can't pass a variable to itself, it has to be either another live template variable (defined before) or some known value calculated based on clipboard content (snakeCase(clipboard())), file name (snakeCase(fileName())), name got from completion, etc.

    If you like to change names of existing variables, you can try String Manipulation plugin, for example