rdfs:comment
| - Here is something for your vimrc which will allow you to restore your cursor position in a file over several editing sessions. This technique uses the viminfo option, so be sure to have viminfo enabled with reasonable options (it is enabled by default): If you are on Unix, the viminfo example above is probably fine as is (but check up on Vim's help for viminfo to see if you like the settings above). For Windows you will need to change the "n" suboption to something like: set viminfo='10,\"100,:20,%,nc:\\some\\place\\under\\Windows\\_viminfo This tip is an improved version of the example given for [
|
abstract
| - Here is something for your vimrc which will allow you to restore your cursor position in a file over several editing sessions. This technique uses the viminfo option, so be sure to have viminfo enabled with reasonable options (it is enabled by default): " 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 If you are on Unix, the viminfo example above is probably fine as is (but check up on Vim's help for viminfo to see if you like the settings above). For Windows you will need to change the "n" suboption to something like: set viminfo='10,\"100,:20,%,nc:\\some\\place\\under\\Windows\\_viminfo Afterwards, add the main function that restores the cursor position and its autocmd so that it gets triggered: function! ResCur() if line("'\"") <= line("$") normal! g`" return 1 endif endfunction augroup resCur autocmd! autocmd BufWinEnter * call ResCur() augroup END This tip is an improved version of the example given for [help last-position-jump]. It fixes a problem where the cursor position will not be restored if the file only has a single line.
|