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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: