Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Indent blank lines (IntelliJ IDEA)

Tags:

I'd like to set the IDEA formatter to keep indentations on blank lines. Currently when I reformat my source files, it strips all indents on blank lines.

I could not find anything on Google nor could I find a setting in the formatter.

like image 529
ra4king Avatar asked Feb 24 '13 11:02

ra4king


People also ask

How do I indent lines 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 I indent back in IntelliJ?

You can configure IntelliJ IDEA to detect the indentation style in the current file and use this style instead of the indents specified in the code style settings for a specific language. Press Ctrl+Alt+S to open the IDE settings and select Editor | Code Style.

How do I set tab space in IntelliJ?

In IntelliJ IDEA, to convert existing tabs to spaces or vice versa, use File → Edit → Convert Indents → To Spaces (or To Tabs). The Reformat code shortcut Ctrl + Alt + L will also do this, while applying other changes.


2 Answers

You can't make IntelliJ IDEA add indentation to blank lines, but you can prevent it from removing them, as shown in this answer to this question.

Settings | Editor | Strip trailing spaces on Save -> None.

like image 126
Michael Dorst Avatar answered Oct 23 '22 04:10

Michael Dorst


The IntelliJ IDEA formatter does not indent blank lines and does not provide any option to do so.

like image 35
yole Avatar answered Oct 23 '22 03:10

yole