How can indentation be automatically (not manually) corrected in IntelliJ?
In Eclipse, it's possible to just highlight the code that needs indenting, right-click, and select Source
> Correct indentation
.
Is there any method for doing the same thing in IntelliJ?
Code
→ Reformat Code...
(default Ctrl + Alt + L) for the whole file or Code
→ Auto-Indent Lines
(default Ctrl + Alt + I) for the current line or selection.
You can customise the settings for how code is auto-formatted under File
→ Settings
→ Editor
→ Code Style
.
To ensure comments are also indented to the same level as the code, you can simply do as follows: