Avoiding whitespace in empty lines
Hello,
When using IntelliJ, it's creating a lot of redundant whitespace.
If you're typing in indented code (= always), and press enter twice in a row, then the empty line will still have all the spaces in it, with nothing behind this. And I always have to clean these up manually, which is not a pleasure!
The fact that your cursor is at the right indentation on the line where you start typing is very great and handy, but the whitespace up to that point on the previous line sucks...
Is there any IntelliJ setting to not create these lines with useless spaces if I press enter twice? I'm using version 9.0.4 Ultimate.
P.S. it should not affect already existing lines ending in whitespace to not affect the version control history of lines I didn't edit.
Thanks!
请先登录再写评论。
Aardwolf,
There is a settings that tells IDEA to strip trailing white-space at the time files are saved. One mode enables it for all lines and the other foronly those lines that were changed during editing.
To control these settings, look in the Editor section of the Settings dialog (enter "strip" into the filter field to zero in on it quickly) and select one of the modes from the pop-up menu labelled "Strip trailing space on Save:"
Randall Schulz
EDIT2:
Cool, that's interesting. Too bad this setting works only so-so, it seems it affects everything except the most recent empty line with spaces. Or something like that. At least when saving, some spaces are removed, on some lines not, and the ones not removed clearly have a green bar left of them indicating it are new (= modified) lines. But it's better than nothing :)
Hi.
IDEA intentionally does not erase white space, if this may move the caret. I.e. if the caret is right after the white space, last in the line. Sudden caret jumps may make typing inconvenient.
Alexander.
On Mon, 21 Mar 2011 16:30:51 MSK, Aardwolf <no_reply@jetbrains.com>
wrote, quoted or indirectly quoted someone who said :
>If you're typing in indented code (= always), and press enter twice in a row, then the empty line will still have all the spaces in it, with nothing behind this. And I always have to clean these up manually, which is not a pleasure!
I use a little C utility every once in a while on the source tree to
clean that up. It also removes runs of more than one blank line.
See http://mindprod.com/products.html#SOURCE
It is quite small, mindless and fast.
I have a companion called Untouch
http://mindprod.com/products.html#UNTOUCH
that puts file dates back the way they were for files that were not
really changed.
--
Roedy Green Canadian Mind Products
http://mindprod.com
If you think it’s expensive to hire a professional to do the job, wait until you hire an amateur.
~ Red Adair