From 09ba3e53f6c3e88f1a703104fc148b0da86a379f Mon Sep 17 00:00:00 2001 From: Spenser Truex Date: Thu, 14 Jan 2021 03:23:08 +0000 Subject: [PATCH] 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 --- .config/nvim/init.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index bf982c1..65883d7 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -113,7 +113,8 @@ 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 * %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