sponsor Vim development Vim logo Vim Book Ad

basic Tip #286: Recover after doing something... ugly.

 tip karma   Rating 161/54, Viewed by 2566 

Read and edit this tip on the Vim tip wiki. The wiki may have a more recent version of this tip.

created:   July 23, 2002 1:07      complexity:   basic
author:   Little Dragon      as of Vim:   5.7

I was once editing a file and wanted to test something. The test was meant to add a line at the end of the file, from outside vim. All was fine, but instead of >>, I wrote >. You can imagine what happened... :)

If you happen to do something like that, the solution is:

:recover

 rate this tip  Life Changing Helpful Unfulfilling 

<< Don't use the escape key! | Cool trick to change numbers >>

Additional Notes

nitya, July 25, 2002 9:55
This command works only if you have swap file. But in case you don't have swap file, u'll not be able to recover ur file
mikael _at_ alminde _period_ _organisation_, September 9, 2006 2:11
A note for the non-*nix using <del>bastards</del> folks out there.
When adding the output of a program to a file you write
    `program >> file`
However, when you want to *replace* a file with the output of a program you write
    `program > file`
Meaning that a simple omission of a > can result in the complete deletion of the file.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Sponsored by Web Concept Group Inc. SourceForge.net Logo