Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I disable persistence undo in Vim 7.3?

I found that sometime, after doing some code modification, I want to go back to the state that i just open that file. But if have such persistence undo option, when i pressing u , it will undo more than i want.

share|improve this question
Pressing U should step back through the edit tree. like ctrl and z in word. I'm not sure I understand, if you press U is it doing too much in which case are you sure you have the undo buffer active? – David McGowan Sep 9 '12 at 13:17
the persistence undo will also save my edit history after i close the file. so when i reopen the file again, when i press U, it can undo my previous change I close the file. that is not i want :( – Kit Ho Sep 9 '12 at 13:26
up vote 4 down vote accepted

Persistent undo is an opt-in feature. If you don't want it simply remove the related settings that you have put in your ~/.vimrc.

Removing set undofile and manually deleting the undo files should be enough.

See :help persistent-undo.

share|improve this answer
Note that the vimrc_example.vim includes set undofile by default now. So user who source vimrc_example.vim in their own .vimrc may be getting this option without intending to. – Ben Apr 1 '14 at 18:17

A solution without disabling persistent undo would be the :earlier 1f command. This rewinds the undo history to where it was the last time the file was saved. (You can keep executing it to go to each previous save spot, or supply a number other than 1 to skip several saves.)

share|improve this answer

I prefer this simple solution:

Append set noundofile to $HOME/.vimrc file (if the file doesn't exist, create it).

Alternatively, as suggested by romainl, you can also find the set undofile line in you vim configuration files and remove it. There are at least three configuration files for vim:

  • system vimrc file: "$VIM/vimrc"
  • user vimrc file: "$HOME/.vimrc"
  • 2nd user vimrc file: "~/.vim/vimrc"
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .