Redundant whitespaces

It seems that Linux kernel developers do not like redundant whitespaces (e.g. trailing whitespaces, space in indent followed by tab). So if we are to submit a patch, it is a courtesy to remove these redundant whitespaces.

If we have git installed, we can check our patch using the following command suggested by Herbert Xu:

git apply --check --whitespace=error-all <patch filename>

Jan Engelhardt has an editor agnostic solution:

find . -type f -print0 | xargs -0 grep -Pn '[\t ]+$'

Kyle Moffett added the following to .vimrc to enable automatic highlighting:

" Show trailing whitespace and spaces before tabs
hi link localWhitespaceError Error
au Syntax * syn match localWhitespaceError /\(\zs\%#\|\s\)\+$/ display
au Syntax * syn match localWhitespaceError / \+\ze\t/ display
Advertisements