【问题解决】vim 打开文档后提醒 E325: ATTENTION 怎么办?

这是经典的 vi/vim 的报错情形。

 

在 Linux 下,使用 vim 或是 vi 查看文件时,可能每次都会出现下面贴出的 E325 错误提醒,然后按 E 进行 Edit anyway 才能继续读写文件。

这个 vim/vi 的报错提醒,如果不处理,每次编辑文本都会出现,很添麻烦。

 

下面,直接介绍一下解决办法:

 


E325: ATTENTION Found a swap
file by the name ".tmp.log.swp" owned by: cctv dated: Sat Nov 23 14:57:00 2019 file name: ~/tmp.log modified: YES user name: cctv host name: centos-T process ID: 29468 While opening file "tmp.log" dated: Sat Nov 23 22:24:17 2019 NEWER than swap file! (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 tmp.log" to recover the changes (see ":help recovery"). If you did this already, delete the swap file ".tmp.log.swp" to avoid this message. Swap file ".tmp.log.swp" already exists! [O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:

 

解决办法

在报错文件的同一路径下,执行此 Bash 命令来显示出该文件夹下的所有隐藏文件:

ls -la

在 Linux 下,隐藏文件的文件名第一个字符,都是一个小句点。

 

然后,找到并删除与你的报错文档同名的 swp 文件即可。

如你的错误文件的文件名是 tmp.log,那么,对应的 vi 缓存隐藏文件,文件名应该是 .tmp.log.swp。没错,删掉它就好。

 

rm -y .tmp.log.swp

 

执行这条 rm 命令时,记得文件名改为你的文件名对应的 swp 文件。很简单,前面加 . 后面加 .swp 。只删除 swp 文件就好,不要误删了你的原文档文件。

 

这样基本就搞定啦。测试一下,再使用 vi/vim 编辑你的文件,应该就再没有 Edit anyway / Abort 的 E325 提醒了。

 

附:

一般对应的 swp 文件,都在你的报错文件的同一路径下,如果没有,说明同一路径下 vi/vim 没有创建文档的资格,它会把 swp 文件创建在其他地方。

那么细读 E325 报错时的屏幕信息,应该能找到对应的 swp 文件路径。找到后,去删了即可。

 

如果本篇文章帮助了你,请在文章末尾给我点一个推荐。感谢!

 

以上。

 

风尾留。

 

 

 
posted @ 2019-11-28 16:54  风尾  阅读(1852)  评论(0编辑  收藏  举报