Skip to content

Instantly share code, notes, and snippets.

@jetpks
Created October 26, 2011 21:09
Show Gist options
  • Save jetpks/1317871 to your computer and use it in GitHub Desktop.
Save jetpks/1317871 to your computer and use it in GitHub Desktop.
Get vim to remember your cursor position.
" Tell vim to remember certain things when we exit
" '10 : marks will be remembered for up to 10 previously edited files
" "100 : will save up to 100 lines for each register
" :20 : up to 20 lines of command-line history will be remembered
" % : saves and restores the buffer list
" n... : where to save the viminfo files
set viminfo='10,\"100,:20,%,n~/.viminfo
function! ResCur()
if line("'\"") <= line("$")
normal! g`"
return 1
endif
endfunction
augroup resCur
autocmd!
autocmd BufWinEnter * call ResCur()
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment