vim编辑文件出错 swap file “*.swp”already exists!

在linux中使用vim编辑文件时,很常见的一个问题,若没有正确定的退出编辑,系统会生成一个隐藏文件.**.swp,此时若再次进入编辑,都会提示错误If you did this already, delete the swap file ".**.swp",若要想再次正确编辑文件,必须先删除.**.swp文件。
错误信息如下:

E325: ATTENTION
Found a swap file by the name ".11-1.c.swp"
          owned by: fairy   dated: Tue Dec 18 19:44:18 2018
         file name: ~fairy/Unix_Code/Chapter11/queue_2.0/11-1.c
          modified: no
         user name: fairy   host name: ubuntu
        process ID: 2239 (still running)
While opening file "11-1.c"
             dated: Tue Dec 18 16:48:41 2018

(1) Another program may be editing the same file.  If this is the case,
    be careful not to end up with two different instances of the same
    file when making changes.  Quit, or continue with caution.
(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r 11-1.c"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file ".11-1.c.swp"
    to avoid this message.

Swap file ".11-1.c.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort: 

解决办法,切换到编辑文件所在的目录,执行:

rm .**.swp 

VIM中解决swap file “*.swp”already exists!文件已打开

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容