Reformatting code in a directory

How to reformat code directory by directory.

Reformatting a Whole Directory

Alternatively, you can reformat a specific directory. This option is really useful if you're reformatting a larger project in stages. You can perform the reformat at directory with ⌘1 (macOS) / Alt+1 (Windows/Linux) to display the Project Window and then right-click on the directory you want to reformat. From the context menu you can press the Reformat Code option to reformat all the code in that directory:

Options to reformat a directory

Alternatively, you can select the directory and use ⌘⌥L (macOS) / Ctrl+Alt+L (Windows/Linux) to display the same dialog.

EditorConfig

IntelliJ IDEA also supports EditorConfig files. In the next step of this tutorial we will take a look at why they're useful and how to use them.