Is there any way to beautify my php code in PhpStorm? (a keyboard shortcut would be preferable)
All you need is to export settings from Eclipse (go to Eclipse's Preferences → Java → Code Style → Formatter and export the settings to an XML file via the Export All button.), and then open IntelliJ IDEA Settings → Code Style → Java, click Manage, and import that XML file by simply clicking Import.
Press Ctrl+Alt+S to open the IDE settings and select Editor | Code Style. To configure a scheme for new projects, go to File | New Projects Setup | Settings/Preferences for New Projects | Editor | Code Style. Select the language for which you want to configure the code style.
If you need to adjust indentation settings, in the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | Code Style. On the appropriate language page, on the Tabs and Indents tab, specify the appropriate indents options and click OK.
Choose Code | Reformat Code
, or press Ctrl + Alt + L.
EDIT: The keyboard shortcode has changed since PHPStorm 10 for windows to Ctrl + Alt + F
Select code to reformat and press Ctrl + Alt + Shift + L
This is tested and working (Ubuntu), cheers!
For Mac:
Select code to reformat and press Command + Alt + Shift + L
For full page code reformat Alt + Command + L
Tested in phpStorm 2018.1.1
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