How can I set up that the code is reformatted automatically on saving?
So I don\'t always have to press Ctrl + Alt + L.
From v2017.2.4 CTRL + ALT + L doesn't work. Use alt + F8 instead.
Solution: Use: ALT + F8 to format the code.
When creating a macro as described by Luca Mastrostefano, use:
alt + F8 to format and then ctrl + alt + s to save.
Actually it is possible.
The idea is to record a very simple macro that selects all the lines (Ctrl+A), formats (Ctrl+Alt+L), deselect all (Up and Down arrow) and saves a file (Ctrl+S), and bind this macro to Ctrl+S.
Free Ctrl+S changing keyboard shortcut for "Save all"
Record the macro
Assign Ctrl+S to "Format and Save"
Finally, enjoy PhpStorm!
I use Save Actions Plugin https://plugins.jetbrains.com/plugin/7642-save-actions for PhpSorm
Another thing that I found very helpful in combination with this macro is the
Show Reformat File Dialog.
In case you want to only reformat the code you just changed, you can set the option:
Only VCS changed text
The dialog can be opened through the following shortcut:
CTRL+ALT+SHIFT+L