linux下vi编辑某文件时,操作出现 错误提示: E325: ATTENTION 2, Found a swap file by the name ".p1.c.swp"

当我在linux下用vi打开p1.c文件时

root@iZ2zeeailqvwws5dcuivdbZ:~/1/01/指针# vi p1.c

会出现如下信息:

 1 E325: ATTENTION
 2 Found a swap file by the name ".p1.c.swp"
 3           owned by: root   dated: Fri Jan  5 19:57:58 2018
 4          file name: ~root/1/01/指针/p1.c
 5           modified: YES
 6          user name: root   host name: iZ2zeeailqvwws5dcuivdbZ
 7         process ID: 10876
 8 While opening file "p1.c"
 9              dated: Fri Jan  5 19:51:30 2018
10 
11 (1) Another program may be editing the same file.  If this is the case,
12     be careful not to end up with two different instances of the same
13     file when making changes.  Quit, or continue with caution.
14 (2) An edit session for this file crashed.
15     If this is the case, use ":recover" or "vim -r p1.c"
16     to recover the changes (see ":help recovery").
17     If you did this already, delete the swap file ".p1.c.swp"
18     to avoid this message.
19 
20 Swap file ".p1.c.swp" already exists!
21 [O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort: 
上面的两段话(1)(2)的翻译是:
(1)另一个程序可能正在编辑同一个文件。 如果是这种情况,请注意在进行更改时不要以相同文件的两个不同实例结束。 退出,或继续谨慎。
(2)此文件的编辑会话崩溃。如果是这种情况,请使用“:recover”或“vim -r p1.c”来恢复更改(请参阅“:help recovery”)。如果已经这样做, 删除交换文件“.p1.c.swp”以避免此消息。

原因是我之前有一次使用vi 操作 p1.c 文件时出现了异常中断,与服务器中断连接了,所以我重新连接服务器后,用 i p1.c 查看时,在当前目录下产生了一个 .p1.c.swp 文件。

但是我使用ls命令查看该目录下,却发现没有这个文件,后来使用ls -a命令查看才知道 .p1.c.swp 是一个隐藏文件。

注:以.开头的文件就是隐藏文件哦。

当我把该隐藏文件删除后再次打开就没有上面的警告了。

root@iZ2zeeailqvwws5dcuivdbZ:~/1/01/指针# rm .p1.c.swp

root@iZ2zeeailqvwws5dcuivdbZ:~/1/01/指针# 

  

原文地址:https://www.cnblogs.com/chenmingjun/p/8207373.html