Intellij IDEA, format all code in a project

Choose the "whole project" radio button instead of the individual file when you ask to reformat.

Just be aware of one problem: If you're working on a larger project with other developers who don't conform to your style, and you're using IntelliJ to transform all their code every time you edit it, you might be causing a problem with your version control system. It will long a huge volume of changes when you check in, and few of them will have anything to do with changing functionality. Better to conform to the group style in that case.


According the iDea: Editor basics documentation:

You can use the shortcut Ctrl+ALT+L (Windows/Linux) or ⌥⌘+L (MAC OS X) and select the Rearrange entries option to reformat the code in the current file or reformat a module or directory (after selecting more than one file).

You can also Right-click a module, file, or directory from the context menu and select Reformat Code and also select the Rearrange entries option.

enter image description here

You can also optimize the imports of your files by selecting the Optimize imports option.

Is some Linux versions the shortcut Ctrl+ALT+L can lock the screen, so you will need to Right-click a file or directory from the context menu and select Reformat Code and also select the Rearrange entries option.

This works for most of the Jetbrains IDES (iDea, PyCharm, WebStorm, RubyMine, and so on.)


In the tree-structure, right click on the folder you like to reformat, choose "Reformat code" from the menu.