Returning to the last cursor position in Vim
Add this to your ~/.vimrc:
augroup line_return " Return vim to the last known position
au!
au BufreadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ execute "normal! g'\"" |
\ endif
augroup END
This snippet will return you to the last known cursor position when opening a file in vim. Very handy!
Written by Akshay
Related protips
1 Response
If you want to do this manually when you are already in a file, use gi
. Very handy when 'scrolling' through a file and you last positions went off screen.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#