最近在使用Vim编辑器使用的时候遇到一个问题,由于公司业务的需要,修改配置电脑端口,就进行常规的终端命令行操作,结果就遇到了一个E325:ATTENTION错误的提示信息,具体提示如下所示:
E325: ATTENTION
Found a swap file by the name "/etc/.hosts.swp"
owned by: root dated: Thu Mon Mar 16 15:47:09 2020
file name: /private/etc/hosts
modified: YES
user name: root host name: chenMac.local
process ID: 3200X
While opening file "/etc/hosts"
dated: Mon Sep 7 15:44:52 2020
(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 /etc/hosts”
to recover the changes (see ":help recovery").
If you did this already, delete the swap file "/etc/.hosts.swp"
to avoid this message.
Swap file "/etc/.hosts.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:
通过上述错误描述,可以很直观的看到解决这个错误的方法,有两个解决方法,本案例是基于Mac电脑系统下的终端为例来解释说明的。造成这个原因的出现也是由于在编辑该文件的时候异常退出了,因为vim在编辑文件的时候会创建一个交换文件来保证文件的安全性,为了去掉这个警告提示,只用删除该文件即可。具体操作如下所示:
方法一:直接在最后提示的选项中,按下电脑键盘“D”键,直接将临时文件删掉即可;
方法二:在Mac电脑的终端中输入命令行: cd /usr/local/ect 回车;接着输入命令行:ls -a 回车;最后输入命令行:rm -rf .hosts.swp 回车 即可。
消除提示之后,进行电脑的端口修改操作,结果保存不成功,直接使用强制保存处理,具体操作如下所示:
以上就是本章全部内容,欢迎关注三掌柜的微信公众号“iOS开发by三掌柜”,三掌柜的新浪微博“三掌柜666”,欢迎关注!