On 5/15/07, Tushar Desai <[EMAIL PROTECTED]> wrote:
This tip (which restores cursor to the last position in previous
editing session) is the lifeline of any developer and it works great
for me at work (on Fedora Core 6).
I've Ubuntu 7.04 @home and I just compiled and installed vim7.1 and
this doesn't work for me. It didn't work with vim7.0 either.

Actually, even on Ubuntu it works if I don't quit from vim. On FC6,
irrespective of the quit. I suppose on ubuntu this is some how not
being "remembered". So, how do I get my cursor back across session
quits?

Regards,
-tushar.

PS: Pardon me for some lame questions, while I try to improve my vim skills.


Actually this problem came up something like 3-4 days ago.  First off,
you need to make sure that you have permissions to read and modify
~/.viminfo .  It appears that sudo'ing can mess that up.  After that
you can just put this (from tip 80?) into your .vimrc

augroup JumpCursorOnEdit
   au!
     autocmd BufReadPost *
         \ if expand("<afile>:p:h") !=? $TEMP |
         \   if line("'\"") > 1 && line("'\"") <= line("$") |
         \     let JumpCursorOnEdit_foo = line("'\"") |
         \     let b:doopenfold = 1 |
         \     if (foldlevel(JumpCursorOnEdit_foo) >
foldlevel(JumpCursorOnEdit_foo - 1)) |
         \        let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 |
         \        let b:doopenfold = 2 |
         \     endif |
         \     exe JumpCursorOnEdit_foo |
         \   endif |
         \ endif
       " Need to postpone using "zv" until after reading the modelines.
       autocmd BufWinEnter *
       \ if exists("b:doopenfold") |
       \   exe "normal zv" |
       \   if(b:doopenfold > 1) |
       \       exe  "+".1 |
       \   endif |
       \   unlet b:doopenfold |
       \ endif
augroup END

I had the same issue from Ubuntu upgrades and that fixed it.

Hope that helps!

-fREW

Reply via email to