I have the following line in my .vimrc
.
autocmd BufWritePre * silent! v/\_s*\S/d
This strips empty lines at the ends of files, on save. The problem is, when it strips the lines it also moves the cursor to the last line of the file. Is there anyway to avoid modifying the cursor location?
function! <SID>DelEmptyLinesEnd()
let l = line(".")
let c = col(".")
v/\_s*\S/d
call cursor(l, c)
endfunction
autocmd BufWritePre * :call <SID>DelEmptyLinesEnd()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With