Ubuntu 用vim编辑文件发现交换文件的错误

当使用Vim编辑器遇到由上一次编辑会话异常终止导致的Swap文件冲突时,本文提供了解决方案。具体操作包括确认是否有其他程序正在编辑同一文件,谨慎避免多个实例同时修改,或通过':recover'命令恢复更改,最后删除'.swp'文件避免重复提示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用类似vim ~/.config/user-dirs 编辑文件时,发现以下这些错误提示:

Found a swap file by the name “.install.log.swp”
owned by: root dated: Sat May 1 10:52:16 2010
file name: ~root/install.log
modified: no
user name: root host name: localhost.localdomain
process ID: 14389 (still running)
While opening file “install.log”
dated: Sat Jan 30 21:31:27 2010

(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 install.log”
to recover the changes (see “:help recovery”).
If you did this already, delete the swap file “.install.log.swp”
to avoid this message.
“install.log” 892L, 33018C
Press ENTER or type command to continue
原因是上次修改的文件不正常退出,导致在编辑这个文件时,出现同时打开的情况。我是直接删除了里面结尾为.swp的文件,然后没有出现提示,删除命令用rm+文件名。
参考 vim错误提示解决方法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值