I\'m looking for a way to auto-format my code in the WebStorm IDE?
If you don't have ALT on your MAC it is:
COMMAND + OPTION + L
Mac: Command + Option + L
PC: Ctrl + Alt + L
It is possible by creating a macro that formats the code and save it, and then bind this macro to Ctrl+S shortcut. (Mac: Cmd+S)
This answer was posted for phpStorm and it is equally valid for WebStorm. A modified version of answer is as follows:
Record the macro
Assign Ctrl+S to "Format and Save"
That's it.
"Save Actions" plugin can format code when saving.
Install plugin:
File -> Settings -> Plugins -> Browse repositories;
Config plugin:
File -> Settings -> Other Settings
>
Marketplace.Save Actions
into search field.Reformat file
> Press OK button.Visit Plugin Homepage