Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij IDEA 14 - remove indents on empty lines

I have an annoying bug regarding intellij 14.0.3. The issue is that it keeps indents on empty lines and I can't remove that whitespace in any way. Under code style, I have not checked the checkbox "keep indents on empty lines" and judging from the display how that functionality works I'd say it would do it.

However, it still keeps the indents and that creates bad diffs in git since whitespace is added. Is this a bug? Can I in any way remove them? I have tried to uncheck that checkbox under both the language I use and the main one. None of them seems to change it.

like image 822
Ms01 Avatar asked Feb 12 '15 11:02

Ms01


1 Answers

Try enabling the Strip trailing spaces on save option in Settings/Editor/General.

You can choose whether this should be performed for All lines or only the lines you modify to avoid creating unnecessary diffs.

The whitespace is stripped when you explicitly hit CTRL+S or automatically after some period (IntelliJ has autosaving).

One thing to note is that if you have cursor on an empty line and there are some spaces before it, hitting CTRL + S won't strip the whitespace, because this would probably be annoying as your cursor would jump to the beginning of the line if the file was autosaved by IntelliJ (I read somewhere on YouTrack that this was a design decision).

Here is a screenshot of the option I describe:

enter image description here

like image 129
Bohuslav Burghardt Avatar answered Sep 26 '22 04:09

Bohuslav Burghardt