4

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

4

2 回答 2

6

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.

于 2010-09-13T11:24:27.770 回答
4

把它放到你的 .vimrc 中

set viewoptions=cursor,folds

au BufWinLeave * mkview

au BufWinEnter * silent loadview
于 2010-09-13T16:58:47.800 回答