Resets cursor pos on save. (line and column)

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

View File

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