Am 14.08.2010 14:41, schrieb Bram Moolenaar:

Andy Wokula wrote:

I'm trying to get used to persistent undo, but hmmm, I find it still a
bit difficult to use.

What I want is persistent undo enabled for certain files (not enabled in
the vimrc, I don't want all the undo files).

So I thought it would be enough to  :setlocal undofile  when it's
needed, and an easy and reliable setup would be to place 'undofile' in
the modeline - this way I cannot forget to set the option for the file.

But it doesn't work.  What works is to set 'undofile' BEFORE editing the
file (which is surprising, and I can't think of a technical reason).

It would be nice if persistent undo would try harder to continue the
undo history.

Ideally, 'undofile' can be set at any time, and the undo file is loaded
then (if 'undofile' was off); if possible, recent changes (collected
while 'undofile' was off) are added to the history of the undo file,
making up the new history.

Comments?

It's not that easy, because when you set 'undofile' Vim has to compute a
checksum of the text to verify that it matches the undo file.  Reloading
the file would be the simple solution.  Adding code to separate the
functionality from reading the file is possible, requires some work.

Why not use an BufReadPre autocommand?  Usually you can come up with a
file pattern (directory, extension) to decide whether to use 'undofile'.

Ok, I can use that, but I think it is not that easy.

I've created a plugin.  So far I'm happy with it, and I start to like
persistent undo.  It's really nice at times to go back to the very beginning
of a file's life, and see how it grows up ;)

undofile.vim
http://www.vim.org/scripts/script.php?script_id=3198

--
Andy

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui