File recovery after power failure in Vim

Source: Internet
Author: User
In Vim, the file recovery operation may not be performed using Vim in Linux many times, but some people do not know that Vim still has the file recovery function after an abnormal power failure. (Vim, you can also understand Vi. Vi on many machines is equivalent to Vim. you can use the alias command to view details. if ViVim ,...
In Vim, the file recovery operation may not be performed using Vim in Linux many times, but some people do not know that Vim still has the file recovery function after an abnormal power failure. (Vim, you can also understand Vi. Vi on many machines is equivalent to Vim. you can use the alias command to view details. if Vi is Vim, it is the same. no matter what, the two editors are similar .) Under www.2cto.com, we will demonstrate how to restore the file: for the demonstration, we have created a file test_vi.txt under the home directory:
Then press Ctrl + Z in command mode to switch to the front-end to achieve power failure:
Then, we use ls-al to view the file, and we will find that there is an additional suffix. swp file, which is a file saved by Vim for each edited file, but it is garbled to open it with Vim.
Then, use vim test_vi.txt to edit the file. you will find a prompt page indicating the reason why the last file failed to exit: www.2cto.com, select R, and press q to exit. After logging out to the console, enter vim-r test_vi.txt. you will find an additional-r parameter. this is a command to restore the file. we will find that:
Press enter as Prompted. at this time, your source file will come out, but don't forget to delete it. if the swp file is not deleted, a prompt will be displayed every time you edit this document.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.