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

link|improve this question

feedback

3 Answers

up vote 3 down vote accepted

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.

link|improve this answer
I'll do that setting.Thanks. – SpawnST May 6 '10 at 7:09
feedback

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.

link|improve this answer
I tried and did not get the right content in the buffer.:( – SpawnST May 6 '10 at 3:35
you must check all registers with :reg ! – user7304 May 9 '10 at 19:28
feedback

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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