Avoid creating unnecessary whitespace when auto indenting


In SublimeText when you press return multiple times the auto indents of the blank lines doesn’t remain (I’ve seen other editors behave like this too, not TextMate though). The way Atom behaves is different, the auto indentation created is left as is. This works poorly with git and other tools that complain about trailing whitespace.

A concrete example, type

def hello_world

then press return twice, you end up on a line indented two spaces, but the blank line above also has two spaces. Repeat in SublimeText (and many other editors), the blank line above will be completely blank.

Please note that this is NOT solved by any strip-trailing-whitespace-on-save feature. That kind of feature is horrible when you work with other people’s code and they use an editor that does not srtrip whitespace. Suddenly your one line change ends up as a hundred line diff because your editor decided to strip whitespace from the whole file, not just where you edited. I think editors should only automatically reformat things on lines the user has edited, otherwise collaboration becomes harder.


If this is integrated, please make it optional. vim does this, it’s difficult to modify that behavior, and I freaking hate it. ಠ_ಠ