Leave a single newline if reducing trailing. (#882)

While removing trailing newlines is a good idea, it is a problem when
editing C files which "must" have an empty line at the bottom.

So we leave just a single newline, if there were any.

Co-authored-by: Spenser Truex <truex@equwal.com>
This commit is contained in:
Spenser Truex 2021-01-14 03:23:08 +00:00 committed by GitHub
parent 17f15d91ee
commit 09ba3e53f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -114,6 +114,7 @@ set noshowcmd
" Automatically deletes all trailing whitespace and newlines at end of file on save.
autocmd BufWritePre * %s/\s\+$//e
autocmd BufWritePre * %s/\n\+\%$//e
autocmd BufWritePre *.[ch] %s/\%$/\r/e
" When shortcut files are updated, renew bash and ranger configs with new material:
autocmd BufWritePost bm-files,bm-dirs !shortcuts