Fortunately, VIM can memorize the last position for me. In its configuration file ~/.vimrc, add these lines at the end:
" Only do this part when compiled with support for autocommands
if has("autocmd")
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif
endif
The secret is that '" records the place where the cursor was before the file was closed last time.
No comments:
Post a Comment