If I'm editing two files with vim, changing to the other file ( :bnext, :bprev ) seems to drop the undo history from the open file - hitting the 'u' key reports "Already at oldest change".

For example:

  1. vim testfile1 testfile2
  2. add some stuff to testfile1
  3. :w
  4. :bn
  5. :bp
  6. u
  7. eep! can't undo!

Is there any way to keep this history for non-visible buffers?

link|improve this question
should this be in superuser or stackoverflow instead? – Ressu Jul 29 '10 at 8:32
@Ressu - good point, how do we tell? Meta question posted: meta.ubuntu.stackexchange.com/questions/47/… – Jeremy Kerr Jul 29 '10 at 8:45
Depending on the outcome of that meta question, I'm likely to delete this. – Jeremy Kerr Jul 29 '10 at 9:24
feedback

3 Answers

up vote 5 down vote accepted

Looks like this will do it:

:set hidden

(in .vimrc)

link|improve this answer
feedback

I know I'm digging up an old thread here, but the newest verson of vim (7.3) has persistent undo, so that you can make a change, close vim completely (even shutdown and restart), restart vim, and undo. In your .vimrc:

" tell it to use an undo file
set undofile
" set a directory to store the undo history, for example:
set undodir=/home/yourname/.vimundo/

Hopefully 7.3 will make it into the Ubuntu repos soon if it hasn't already.

link|improve this answer
woot! I wait with anticipation :D – Jeremy Kerr Feb 17 '11 at 3:05
feedback

You can use Viewports.
"vim -o testfile1 testfile2" - open files in splitted window.
":sp filename" - split and open "filename".
":vsp filename" - vertical split and open "filename".
"Ctrl+w+arrow" - Change viewport.

link|improve this answer
I'd rather not keep a permanently-visible buffer for each file; it's not unusual to have >20 files open at once. – Jeremy Kerr Jul 29 '10 at 8:44
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.