I'm looking for a way to auto-format my code in the WebStorm IDE?
In the editor, select a code fragment you want to reformat. Before reformatting, you can take a look at the code style settings that are applied to the selected code: press Alt+Enter and click Adjust code style settings. From the main menu, select Code | Reformat Code or press Ctrl+Alt+L .
Press F6 or choose Refactor | Move from the context menu or from the main menu. Alternatively, choose Refactor | Refactor This or press Ctrl+Alt+Shift+T , then choose Move from the list. The Move Module Members dialog opens. Specify the destination file and select the members to move.
If you choose Code | Reformat Code from the main menu or press Ctrl+Alt+L , IntelliJ IDEA tries to reformat the source code of the specified scope automatically.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With