The VI Recover Option




The Vi Recover Option.

Here we will outline good crash recovery procedure when working in UNIX. Sometimes a network outage will occur when you are working on a file, or you may do something stupid yourself and crater your connection. If you follow a few basic steps, you can recover your file, or almost all of it. It is always a good idea to "save early and often;" it's just like voting in Chicago. Make it a habit to cleanly exit PUTTY when you are using it so you don't stop on your own vi sessions.

Rule Number One when you make a new file, write it IMMEDIATELY. if you do not save at least once in your editing session, you are cooked. End of story, end of file, could be just the plain old end.

Suppose you are editing crushme.py, and an outage d'system jars your heretofore irenic universe. Perform the following steps promptly.

  1. Log back in.
  2. Go to the directory containing crushme.py and do an ls -a
  3. You will see .crushme.py.swp
  4. Invoke the recover option of vi by typing vi -r crushme.py
  5. Immediately write and quit
  6. Then delete .crushme.py.swp or it keep haunting you and this can ROYALLY screw things up!