Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to format complete project source code in phpstorm?

Tags:

phpstorm

I found reformatting php source code in phpstorm for particular file is Ctrl+Shift+Alt+L. But is there any way to do for whole project files?

like image 296
Bala Avatar asked Nov 13 '15 16:11

Bala


People also ask

How do I format an entire project in IntelliJ?

In the Project tool window, right-click a module or a directory and from the context menu, select Reformat Code or press Ctrl+Alt+L .

How can I beautify code in IntelliJ?

Sometimes code formatting can get out of sync, but there's an easy fix in IntelliJ IDEA. You can use ⌘⌥L (macOS), or Ctrl+Alt+L (Windows/Linux) to reformat a selection of code according to your reformat settings.

How do I enable auto format in IntelliJ?

The formatting shortcuts in Intellij IDEA are : For Windows : Ctrl + Alt + L. For Ubuntu : Ctrl + Alt + Windows + L. For Mac : ⌥ (Option) + ⌘ (Command) + L.


1 Answers

If you have issues opening the "reformat code" popup for multiple files, make sure that you don't have any open files as it'll otherwise only reformat the current open file (edit: sometimes - I still haven't been able to figure out why it allows you to reformat the entire code sometimes, but regardless, this fix will work if it doesn't allow you to).

You can simply right click any file on your file list and select "Close all".

Close all files in PHPStorm 2016.3

After you've done this, select the folder you want to reformat in the code view:

Project overview in PHPStorm 2016.3

Finally, with all files open you can now select "Reformat code" in the "Code" part of your main toolbar:

Reformat Code toolbar item in in PHPStorm 2016.3

You'll now get the regular popup that most guides seem to mention, but that's otherwise hidden for some reason:

Reformat Code popup in PHPStorm 2016.3

like image 56
h2ooooooo Avatar answered Oct 08 '22 19:10

h2ooooooo