Dominique Pellé wrote:
Christian Brabandt wrote:

Hi SungHyun!

On Do, 03 Jun 2010, SungHyun Nam wrote:

With vim-7.3 (+ 'undofile'):
I guess I could remove a undofile and run ':e' to do this.  Maybe
I can make a mapping with some vim script, but...

Is there any easy way to purge 'persistence undo' history?

Try setting ul=-1

I tried this:

:set undolevels?
   undolevels=4000

:set undolevels=-1
:set undolevels=4000

And the undo history was *not* purged.  Undo history is
only purged if I edit something in between the 2
":set undolevels=...":

:set undolevels=-1
.. edit something...
:set undolevels=4000
(undo history is now purged)

I'm not sure how useful it is to be able to purge undo history anyway.
I don't think I would need to do that.  What I would find more
useful, when performing multiple undos with persistent-undo, is to
display a message such as:

"undo reached state where file was last read/written"

... so that user is warned when doing multiple undos that it can
go back in time earlier than when file was last read/written if he
continues to undo.

Well, it might be just my editing style. When I edit a C
source and compile (and test), I purged the undo history (and
maybe checkin to GIT repo).  And edit again, if something is
wrong, I just pressed 'u' until I return to purged state.  So to
me, even the warning message is not perfect, because I want to go
back fast (don't want to check message while I press 'u').

And I made a function, it works for me.

    func! util#purgeUndoHistory()
      let file = undofile(expand('%:p'))
      if filereadable(file)
        let oldundofile = &l:undofile
        setl noundofile
        silent! exec "!rm -f ".file
        e
        let &l:undofile = oldundofile
      endif
    endfunc

I see an item added recently on the todo list which would also be useful:

- undofile: keep markers where the file was written/read, so that it's easy to
   go back to a saved version of the file  ":earlier 1file"?

Cheers
-- Dominique


Thanks,
namsh

--
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