poinck / lampe

control for your Philips Hue lights from Terminal or Gnome
Creative Commons Zero v1.0 Universal
91 stars 4 forks source link

Remove trailing whitespaces #26

Closed FSMaxB closed 9 years ago

poinck commented 9 years ago

I'm afraid sooner or later these whitespaces will come back, because I have no vim-setup that will handle this for me. I am just starting to learn about the power of it. (:

FSMaxB commented 9 years ago

I'm using this plugin to show whitespaces that don't belong there: https://github.com/bitc/vim-bad-whitespace. This plugin will make it so that you are annoyed by any wrong whitespace out there.

If you're not using a plugin manager already, use one, there are many good ones out there. The one I'm using is https://github.com/junegunn/vim-plug, it also works with neovim.

You can take a look at my config files for reference: https://github.com/FSMaxB/config, the Readme is kind of outdated though.

Another plugin that every vim user should install is https://github.com/tpope/vim-sensible

poinck commented 9 years ago

On another computer I have somthing like this, too:

set tabstop=4
set shiftwidth=4
set expandtab

I understand why spaces ar better than tabs, but why those trailing whitespaces are bad despite increase file size and producing commit noise? Besides, I think "shiftwidth" and this "bad-whitespaces"-plugin are in conflict, sort of. I think it would be better to remove trailing whitespaces automatically triggered by ":w" or just before a git commit, because nothing would prevent the developer to forget to call the plugin-function "EraseBadWhitespace" before a commit and then has to do a second commit. Wouldn't that create much more commit noise? Not sure.

FSMaxB commented 9 years ago

I didn't even know that this plugin can automatically erase whitespaces. The point is that it shows trailing spaces in red so that you can't overlook it.

I haven't really thought about why trailing spaces are that bad but I guess it's coming down to editor behaviour being influenced by trailing whitespaces and, more importantly, diffs are much cleaner if whitespaces are normalised and don't appear and disappear randomly. This also makes merging easier if all of the lines follow the same pattern.

You could theoretically make a git commit hook that automatically cleans all trailing spaces but having the editors show them in red works good enough in practice (in my experience at least).

poinck commented 9 years ago

Ok, I will try this.

FSMaxB commented 9 years ago

Fun fact: Just today I happened to have whitespace related problems (non trailing though). I accidentally added a tab character in a line and removed it twice in later commits (in different branches). Rebasing one of those branches on top of the other gave me a merge conflict because of the whitespace.

poinck commented 9 years ago

argh (: