I realized I had deleted something for mistake when I typed :wq,then how can I rollback to the pre-version?Thank you!

3 Answers 3


If you have backups set, you could try looking in your backup folder. In my .vimrc I have a line that says

set backupdir=~/Backups

I can retrieve old versions from there.


If you haven't yanked or deleted anything since then it may still be in the yank buffer and you can paste it in any vim session to show/restore it.

  • I tried and did not get the right content in the buffer.:(
    – SpawnST
    May 6, 2010 at 3:35
  • you must check all registers with :reg ! May 9, 2010 at 19:28

If you have Vim 7.3 (which was not available at the time this question was originally asked) you may enable persistent undo, where undo information is stored and remembered across Vim sessions, by putting in your ~/.vimrc:

:set undofile

You may also want to set the 'undodir' option. See:

:help 'undofile'
:help 'undodir'
:help persistent-undo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.