The easiest thing to do would probably just to do :e after your :w. :e will 
re-read the file, wiping the undo buffer.

Max

> -----Original Message-----
> From: Phil Edwards [mailto:[EMAIL PROTECTED]
> Sent: Monday, February 05, 2007 9:26 AM
> To: [email protected]
> Subject: Clearing undo history after a file write
>
> After writing out a file, I would (sometimes, not always) like to
> prevent 'u' from undoing past the :w into old changes, e.g.,
>
> - change #1
> - change #2
> - :w
> - change #3
> - change #4
> - 'u' undoes #4 and then #3, but then stops
>
> This seems like such a simple thing, but to my surprise it's less
> trivial than I thought it would be.
>
> The only thing in ":help undo" and its related tags which seems to be
> relevant is the undolevels variable.  So maybe something like
>
> - copy undolevels into some temp variable  // I don't remember the
> "let" syntax offhand
> - set undolevels=-1
> - set undolevels=temp_holding_variable
>
> would work?  A value of -1 disables undo altogether, so would this
> sequence kill the history and start it from scratch?
>
>
> -phil

Reply via email to