Is there a
.vimrc setting to automatically remove trailing whitespace when saving a file?
Ideally (to be safe) I would like to only have this functionality for certain files, e.g.
This works (in the .vimrc file) for all files:
This works for just ruby(.rb) files:
To keep cursor position use something like:
else cursor would end up at beginning of line of last replace after save.
Example: You have a space at end of line
Set up call to function using
One can also use, but not needed in this case, getpos() by:
My DeleteTrailingWhitespace plugin does this and, in contrast to the various simple
The plugin page contains links to alternatives; there's also a large discussion on the Vim Tips Wiki.