Mac – How to discard the undo history in vim

gvimhistorymacvimundovim

Undo is nice to have in Vim. But sometimes, at a known good point, I want to erase my undo history – to be able to use u to undo individual changes, but only back to a certain point. (For instance, this might be when I last committed.)

One way to accomplish this would be to close and reopen the file – the undo history starts clean at that point. But that's a hassle.

In the past, I accomplished this with :edit!. But in Vim 7.3, that doesn't discard the undo history.

Is there another way to do this, apart from closing the file?

Best Answer

:set undoreload=0 | edit

should do what you're asking for.

Related Question