Remove trailing spaces using vim
This little function will remove trailing space and maintain your position in a file. I started with something like this.
" Removes trailing spaces
function! TrimWhiteSpace()
%s/+$//e
endfunction
I found that it left me at the bottom of my file, and I kept forgetting to mark my position before running it. After a little research I found this solution, it saves your positon and returns it to you after it's done.
Thanks to stphancheg on stack overflow
" Removes trailing spaces
function! TrimWhiteSpace()
%s/+$//e
endfunction
I found that it left me at the bottom of my file, and I kept forgetting to mark my position before running it. After a little research I found this solution, it saves your positon and returns it to you after it's done.
Thanks to stphancheg on stack overflow
Comments