Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim persistent undo is not working properly

I am trying to use persistent undo with vim 7.4.9

In my vimrc, I have:

set undodir=/home/myname/.vim/undo//
set undofile
set undolevels=1000
set undoreload=10000

of course, /home/myname/.vim/undo directory exists.

I have opened a few files with vim and made a few changes.

I see undofiles created in /home/myname/.vim/undo/:

$ ll /home/myname/.vim/undo/
total 23K
-rw-r--r-- 1 hpcpcollab hpcpcollab  523 18 sept. 11:23 %home%myname%foo
-rw-r--r-- 1 hpcpcollab hpcpcollab  14K 18 sept. 11:03 %home%myname%bar
-rw-r--r-- 1 hpcpcollab hpcpcollab 2,2K 18 sept. 11:52 %home%myname%test

However, when I close these files, reopen them, and press 'u' in order to undo, vim replies: "Already at oldest change".

What am I missing?

Thx

Julien

like image 589
Julien REINAULD Avatar asked Sep 18 '13 10:09

Julien REINAULD


2 Answers

Could patch 7.4.24 perhaps fix your problem? In any case, try explicitly reading the undofile using :verbose :rundo ~/.vim/undo/undofile and see what error Vim reports. This should help localize the problem, why vim doesn't use the undofile.

like image 88
Christian Brabandt Avatar answered Sep 28 '22 05:09

Christian Brabandt


I have the exact same configuration except for the // at the end of your undodir definition. Try to remove those. You can also try the :undolist command to see if vim actually read something.

May I suggest you use the Gundo plugin to manage your undo tree ? It is one of the most powerful plugin I am using, and it offers a lot of features to manage undo / redo in vim.

like image 23
giovanni Avatar answered Sep 28 '22 05:09

giovanni