JaredVogt / vimrc

CONFIG: my vimrc
0 stars 0 forks source link

Set a hotkey to clear out the undo history for a given file #15

Open JaredVogt opened 8 years ago

JaredVogt commented 8 years ago

super long undo is nice... until it isn't

https://groups.google.com/forum/#!topic/comp.editors/AQooGv9gWDE https://gist.github.com/dongminkim/3405006 http://superuser.com/questions/214696/how-can-i-discard-my-undo-history-in-vim

not immediately obvious - in vim help it looks like it saying to temporarily assign your undo levels to temp var, set undo to -1, which clears it - and then write temp var back again and unset the temp.

More research

JaredVogt commented 8 years ago

When you set 'undolevels' to -1 the undo information is not immediately cleared, this happens at the next change. To force clearing the undo information you can use these commands: >

    :let old_undolevels = &undolevels
    :set undolevels=-1
    :exe "normal a \<BS>\<Esc>"
    :let &undolevels = old_undolevels
    :unlet old_undolevels