Practice Recovering a File in Vim

April 1, 2018

 

This post lists steps that allow you to practice file recovery in Vim.

 

Steps

 

1. Open a terminal, create a directory and start editing a file named hello.c:

 

2. Put this text in the file:

 

3. Save the file in Vim:

4. Make a change to the file but _don't_ save:

 

5. Close the terminal.

 

6.

You should see:

 

7. Type 'Q' to quit

 

8. Open the file in recovery mode:

 You should see:

 

9. After pressing ENTER, write the file out to check the recovery:

 

10.

 

10.1 When you see the following type 'O'

 

10.2 Now you should see:

 

 

 

 

Control-w j and Control-w k will let you switch between the windows

 

11. To exit diff mode type:

 

11.1 To remove one of the windows use Control-w j or Control-w k to enter the window then type ZZ. 

12. Now find and save the right buffer. Find the right buffer:

At the following, press '2':

 

13.  Now delete the swap file.

 

13.1 Edit the file

13.2 At this screen type 'D' to delete:

 

14. Now: 

  1. Overwrite hello.c with hello.c.recovered

  2. Delete the hello.c.recovered buffer

  3. ...and delete the hello.c.recovered file

 

15. Check that everything is cleaned up. Run:

You should see

 

 

References

  • Steps adapted from the Vim user doc @ link.

  • The Vim logo is from link.

  • Used the HTML escape feature at FreeFormatter.com for the code blocks.

 

 

 

 

 

 

Please reload

Our Recent Posts

DOCSIS 3.1 Series of Specification and Related Specifications

May 25, 2020

Abbreviations, Acronyms from CM-SP-PHYv3.1-I17-190917 and Notes

May 25, 2020

Install a Vim Package on Vim 8 Running on Windows 7

May 3, 2020

1/1
Please reload

Tags

Please reload

©2018 by Zach Pfeffer

SEARCH THIS SITE