I'm thinking of adding a command to vim for removing
white space from the end of each line of a C source
file. Can anyone think of a situation where such white
space might be useful ?
As several people note, this requires defining "useful".
I will add, here, that attempting to make use of "invisible" trailing
white space in C programs, e.g., by writing a slash-slash comment
(in C99) followed by a backslash followed by a blank followed by
a newline, so that the line following this line appears to be
commented out but actually is not, is a bad idea. This is the
case not only because it is obfuscatory, but also because it may
malfunction on some systems.
There are still some (now rare) file systems Out There that are
unable to distinguish between an "empty" line and a "line consisting
only of blanks". In particular, they see a file as a set of
"records" of fixed length. A line shorter than the fixed record
length is blank-padded, and a line exactly the fixed record length
is left alone. (It is physically impossible to have a line longer
than the record length.) In other words, all lines are exactly
the same length, hence the name "fixed length records".
If a C compiler on such a system reads such files, it will[%] remove
all "trailing blanks" from the file itself, as if you (the OP above)
had used your vim command. So an attempt to use C99 comments to
*pretend* to comment out the next line, on such a compiler, actually
*will* comment out the next line. (One can thus use the attempt
to discover whether the compiler is reading fixed-length records
and stripping trailing whitespace from them.)
[% Actually, it could also leave them in, giving surprising behavior
for what the programmer *thought* were trailing backslashes. The
systems I have heard of do delete trailing white-space, though, to
avoid these surprises.]