summaryrefslogtreecommitdiffstats
path: root/.config/nvim
diff options
context:
space:
mode:
authorSpenser Truex <greetings@spensertruex.com>2021-01-14 03:23:08 +0000
committerGitHub <noreply@github.com>2021-01-13 22:23:08 -0500
commit09ba3e53f6c3e88f1a703104fc148b0da86a379f (patch)
tree6366aec49de62bb560cf47bb1df0a8fe8bec4c92 /.config/nvim
parent17f15d91ee5c90620af6e0fba55180c8c0c93f45 (diff)
downloadeibhear-09ba3e53f6c3e88f1a703104fc148b0da86a379f.tar.gz
eibhear-09ba3e53f6c3e88f1a703104fc148b0da86a379f.tar.zst
eibhear-09ba3e53f6c3e88f1a703104fc148b0da86a379f.zip
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>
Diffstat (limited to '.config/nvim')
-rw-r--r--.config/nvim/init.vim3
1 files changed, 2 insertions, 1 deletions
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