Resets cursor position on file save (Issue #1040) (#1057)

* Resets cursor position on file save (Issue #1040)

* Resets cursor pos on save. (line and column)
This commit is contained in:
Fabian 2021-12-21 02:11:17 +11:00 committed by GitHub
parent ed9a67ed6d
commit a01c9f967b
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 ZZ :Goyo\|x!<CR>
autocmd BufRead,BufNewFile /tmp/neomutt* map ZQ :Goyo\|q!<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 currPos = getpos(".")
autocmd BufWritePre * %s/\s\+$//e autocmd BufWritePre * %s/\s\+$//e
autocmd BufWritePre * %s/\n\+\%$//e autocmd BufWritePre * %s/\n\+\%$//e
autocmd BufWritePre *.[ch] %s/\%$/\r/e autocmd BufWritePre *.[ch] %s/\%$/\r/e
autocmd BufWritePre * cal cursor(currPos[1], currPos[2])
" When shortcut files are updated, renew bash and ranger configs with new material: " When shortcut files are updated, renew bash and ranger configs with new material:
autocmd BufWritePost bm-files,bm-dirs !shortcuts autocmd BufWritePost bm-files,bm-dirs !shortcuts