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

I deleted some lines in a text file with gvim (ma, <move cursor>, d`a), saved and closed gvim. I realized I'd deleted the wrong lines, and opened a new gvim and opened the file, but 'p' did not re-paste the cut lines. The backup file had the version with lines deleted (presumably when I reopened the file it deleted the previous backup).

Is there any way of recovering the missing lines? I have windows 7 and have got shadow copies turned off for the volume.

share|improve this question

migrated from Nov 18 '12 at 15:40

This question came from our site for professional and enthusiast programmers.

You need to set undofile option in your .vimrc:

:set udf
share|improve this answer

With Vim 7.3, if you had :set undofile (persistent undo), you could have simply pressed u to undo.

Too bad that p didn't work; you could still manually check the _viminfo file for the lost contents.

I hope you use this occasion to rethink your backup strategy, various revision control systems are available and quite simple to use. For file system locations where this is not feasible, I use a lightweight alternative in the form of the writebackup plugin.

share|improve this answer

You must log in to answer this question.