I want to remove trailing blank lines (blank lines could also be just a bunch of tabs and spaces).
In my .vimrc I have:
autocmd BufWritePre * :%s#\($\n\s*\)\+\%$## " trim white spaces at the end of file
This works, however if a file has already had its trailing blank lines removed, I get the following error message:
Error detected while processing BufWrite Auto commands for "*":
How may I fix this?
From :help :s_flags:
[e] When the search pattern fails, do not issue an error message.
So you could try:
:%s#\($\n\s*\)\+\%$##e
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