how to align text to specific character in phpstorm or webstorm?

Cmd+Alt+L (in Mac) or Ctrl+Alt+L (Win) and PHP Storm will format code depends of your Code style in Settings. TO set this code style go: File -> Settings -> Code style -> PHP(choose here your language) -> Other -> Align key-value pair - mark as checked. And then press Reformat code (Ctrl+Alt+L) and voila. You will get code, styled you write above.


In PhpStorm 8 that option is in:

File -> Settings -> Code style -> PHP -> Wrapping and Braces -> Assignment statement

formatting option in phpstorm 8

settings > Code Style > php > Wrapping and braces

enter image description here

check both option Align fields in option and Align Constant

now you can get what you want! :)

Source Jetbrains Blog


For me in PhpStorm 8.0.2 I found it here:

Settings -> Editor -> Code Style -> PHP -> Wrapping and Braces -> Align consecutive assignments