Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save scottstanfield/84694d1fdf698d6d1c13 to your computer and use it in GitHub Desktop.
Save scottstanfield/84694d1fdf698d6d1c13 to your computer and use it in GitHub Desktop.
" Put this in your .vimrc
" Jump to the last position of the cursor except for git commits
function! PositionCursorFromViminfo()
if !(bufname("%") =~ '\(COMMIT_EDITMSG\)') && line("'\"") > 1 && line("'\"") <= line("$")
exe "normal! g`\""
endif
endfunction
au BufReadPost * call PositionCursorFromViminfo()
" Jump to the last position of the cursor
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
@scottstanfield
Copy link
Author

I just extracted this from my .vimrc for @icecreammatt. There might be more dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment