Created
February 12, 2021 23:08
-
-
Save sunshine69/87424c6870c5b693ef0c09613ef6747f to your computer and use it in GitHub Desktop.
tell vim not to remember cursor position for a git commit message
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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