Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to correct indentation in IntelliJ

People also ask

How do I fix indenting in IntelliJ?

If you need to adjust indentation settings, in the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | Code Style. On the appropriate language page, on the Tabs and Indents tab, specify the appropriate indents options and click OK.

How do you correct an indent?

Select the text you want to adjust. Go to Home and select Line and Paragraph Spacing > Line Spacing Options at the bottom of the menu. The Paragraph dialog box opens. On the Indents and Spacing tab, select the options you want, and click OK.

How do I change the indent spacing in IntelliJ?

Press Ctrl+Alt+S to open the IDE settings and select Editor | Code Style. Select the Detect and use existing file indents for editing checkbox. Apply the changes and close the dialog.

How do I fix format 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.


CodeReformat Code... (default Ctrl + Alt + L) for the whole file or CodeAuto-Indent Lines (default Ctrl + Alt + I) for the current line or selection.

You can customise the settings for how code is auto-formatted under FileSettingsEditorCode Style.


To ensure comments are also indented to the same level as the code, you can simply do as follows:

UI screenshot (example for JavaScript)


Just select the code and

  • on Windows do Ctrl + Alt + L

  • on Linux do Ctrl + Windows Key + Alt + L

  • on Mac do CMD + Option + L


Select Java editor settings for Intellij Settings Select values for Tabsize, Indent & Continuation Intent (I choose 4,4 & 4)

Then Ctrl + Alt + L to format your file (or your selection).


In Android Studio this works: Go to File->Settings->Editor->CodeStyle->Java. Under Wrapping and Braces uncheck "Comment at first Column" Then formatting shortcut will indent the comment lines as well.