Resets cursor position on file save (Issue #1040)

This commit is contained in:
Fabian 2021-12-20 07:57:07 +11:00 committed by GitHub
parent ed9a67ed6d
commit da0a2b3ae0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,10 +111,12 @@ set noshowcmd
autocmd BufRead,BufNewFile /tmp/neomutt* map ZZ :Goyo\|x!<CR>
autocmd BufRead,BufNewFile /tmp/neomutt* map ZQ :Goyo\|q!<CR>
" Automatically deletes all trailing whitespace and newlines at end of file on save.
" Automatically deletes all trailing whitespace and newlines at end of file on save. & reset cursor position
autocmd BufWritePre * let lineNumb = line('.')
autocmd BufWritePre * %s/\s\+$//e
autocmd BufWritePre * %s/\n\+\%$//e
autocmd BufWritePre *.[ch] %s/\%$/\r/e
autocmd BufWritePre * cal cursor(lineNumb,0)
" When shortcut files are updated, renew bash and ranger configs with new material:
autocmd BufWritePost bm-files,bm-dirs !shortcuts