Saturday, June 9, 2012

Re: Truncate undo list

Hi richard!

On Fr, 08 Jun 2012, richard emberson wrote:

> If one has an undo list, is there a way to
> capture its its given state/length,
> make additional edits, and then go back to
> its captured state/length (with or without backing
> out any new changes) and remove all later members of
> the undo list (no redos) - truncate the undo list.

The undo tree is not meant to be modified, though there are 2 different
workarounds:

1) Take the buffer content and copy it into a new buffer. There you
modify your buffer as you like, without messing with the undo
tree in the original buffer. When you are finished, copy the
data back in the original buffer. The NrrwRgn plugin may be
helpful for this.
2) If the buffer contents at the beginning and end are the same, it
should be possible to write the undo tree once using :wundo. Now
modify your buffer as you like. When finished, discard the
current undo tree, by reading in the old undo tree using :rundo.
For this to work, the buffer contents at the time of
:wundo/:rundo must be exactly the same, else :rundo won't work.
Use :verbose to make sure it works.

regards,
Christian

--
You received this message from the "vim_use" 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

No comments: