Recovering Deleted Text

vi automatically saves the previous nine deletions in numbered buffers. If you delete the wrong thing, you may be able to get it back if you realize it soon enough. Note that many UNIX systems save only text deleted by the d command, not the x command.

Recovering deleted text from numbered buffers

1.
Move the cursor to some empty lines where you can easily see any text that might be recovered.
2.
Enter "1p. The most recently deleted text will be inserted at the cursor.
3.
If this is not what you are looking for, enter u to undo the insert and remove the unwanted text.
4.
Enter a period (.). This inserts text from the next most recent deletion.
5.
If this is not what you are looking for, enter u to undo the insert and ...

Get Practical UNIX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.