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.
- Log back in.
- Go to the directory containing
crushme.py
and do anls -a
- You will see
.crushme.py.swp
- Invoke the recover option of vi by typing
vi -r crushme.py
- Immediately write and quit
- Then delete
.crushme.py.swp
or it keep haunting you and this can ROYALLY screw things up!