How to correct indentation 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:

Leave a Comment