Commit Diffs on GIT normally show trailing whitespaces if set to colored diffs.

$ vim ~/.gitconfig
[color]
        ui = auto
[color "branch"]
        current = yellow reverse
        local = yellow
        remote = green
[color "diff"]
        meta = blue bold
        frag = magenta bold
        old = red bold
        new = green bold
[color "status"]
        added = yellow
        changed = green
        untracked = cyan

[color]
        ui = true
[color "diff"]
        whitespace = red reverse

In order to remove them, the following tips can be used:

Remove trailing whitespaces (at the end):

:%s/s+$//

Delete whitespace at the beginning of each line:

:%s/^s+//
" Same thing (:le = :left = left-align given range):
:%le

To detect them, just put this in your vimrc – before any highlight command:

highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /s+$/
match ExtraWhitespace /s+%#@<!$/
match ExtraWhitespace /s+$/
%d bloggers like this: