Skip to content

Instantly share code, notes, and snippets.

@sunshine69
Created February 12, 2021 23:08
Show Gist options
  • Save sunshine69/87424c6870c5b693ef0c09613ef6747f to your computer and use it in GitHub Desktop.
Save sunshine69/87424c6870c5b693ef0c09613ef6747f to your computer and use it in GitHub Desktop.
tell vim not to remember cursor position for a git commit message
in vimrc
the first section is enable the feature, the last is to auto jump to line 1 if in the git commit message so
if we set EDITOR=vim and run git commit it will always set insertion cursor at line 1
>>>>>
if has("autocmd")
augroup fedora
autocmd!
"...
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal! g'\"" |
\ endif
"...
augroup END
endif
function! GoTopFile()
exe "normal! 1G"
endfunction
autocmd BufReadPost COMMIT_EDITMSG :call GoTopFile()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment