I've the following
autocmd for stripping trailing whitespace in a buffer, every time the buffer is written to a file:
" trim whitespace autocmd BufWritePre * %s/\s\+$//e
autocmd has the annoying side effect of moving the cursor, when there are lines that match the substitution:
How can I prevent the
autocmd from moving the cursor?