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

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

......
......
(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 -rf .**.swp]

[root@king playbook]# ls -a  //查看所有文件包括隐藏文件
[root@king playbook]# ls -a
.  ..  play.yml  .play.yml.swp
[root@king playbook]# rm -rf .play.yml.swp

再次vi/vim编辑进去就不会报问题!

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值