Currently, in my .vimrc file, I have a function that clears all spaces in spaces while saving, preserving my mouse position.
fun! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$
call cursor(l, c)
endfun
autocmd BufWritePre *.sql,*.php :call <SID>StripTrailingWhitespaces()
This works great. But I would like to add a few more things, for example:
* Delete carriage return
* Fix SP indent, followed by TAB
I tried adding
% s / ^ M // e
for my function StripTailingWhitespaces(), but when I save vim it tells me
Press ENTER or enter a command to continue
So, I think I did something wrong or forgot something. Any help on defining this? thank
:. . <CR> StripTrailingWhitespaces, BufWritePre. . , "Trailing Spaces". ?
, SP, TAB?