Vim persistent undo 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 there is a directory /home/myname/.vim/undo.

I opened several files with vim and made some changes.

I see flaws 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, open them again and press 'u' to cancel, vim replies: โ€œAlready at the oldest changeโ€.

What am I missing?

thanks

Julien

+4
source share
3 answers

Perhaps fix 7.4.24 can solve your problem? In any case, try to explicitly read the undofile with :verbose :rundo ~/.vim/undo/undofile and see what error Vim reports. This should help isolate the problem of why vim is not using undofile.

+2
source

I do not know the reason, but you can use a workaround. Create an autocommand that reads the directory in which you save the undo history immediately after downloading the file for editing:

 au FileReadPost * rundo /home/myname/.vim/undo 
0
source

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

Can I suggest using the Gundo plugin to manage the undo tree? This is one of the most powerful plugins I use, and it offers many features to control undo / redo in vim.

0
source

Source: https://habr.com/ru/post/1502779/


All Articles