vim option

D. Michael McIntyre michael.mcintyre at rosegardenmusic.com
Mon Jun 25 22:35:43 UTC 2007


On Monday 25 June 2007, adams wrote:
> I am looking for the option that allows me to start up
> editing in a previous file where I left off.

I had to dig something up on the internet to fix this.  It's like nothing I 
ever used to have in any vimrc, and I don't understand why all of this is 
necessary, but it works.  Shrug.  I pasted it into my ~/.vimrc and forgot all 
about it until your question came up.

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



-- 
D. Michael McIntyre 




More information about the kubuntu-users mailing list