Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim start with cursor where last went off [closed]

How do i make Vim always start at the line I was at when i exited that given file last time?

like image 604
john-jones Avatar asked Dec 29 '22 07:12

john-jones


2 Answers

Put this in your .vimrc:

" When editing a file, always jump to the last cursor position
 au BufReadPost *
       \ if ! exists("g:leave_my_cursor_position_alone") |
       \     if line("'\"") > 0 && line ("'\"") <= line("$") |
       \         exe "normal g'\"" |
       \     endif |
       \ endif

then you can use :let g:leave_my_cursor_position_alone=1 at runtime to deactivate the feature.

like image 70
Marco Mariani Avatar answered Jan 05 '23 15:01

Marco Mariani


put this into your .vimrc

set viewoptions=cursor,folds

au BufWinLeave * mkview

au BufWinEnter * silent loadview
like image 45
Aleksandr Zavatskiy Avatar answered Jan 05 '23 15:01

Aleksandr Zavatskiy