目 录CONTENT

文章目录

linux下vi或vim操作Found a swap file by the name的原因及解决方法

ByteNews
2021-03-02 / 0 评论 / 1 点赞 / 3,783 阅读 / 1,350 字 / 正在检测是否收录...
温馨提示:
本文最后更新于 2022-02-02,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

linux下vi或vim操作Found a swap file by the name的原因及解决方法

原因是在此次 vi 或 vim 操作前有过一次使用 vi 或 vim 操作 Test.java 文件时出现了异常中断,所以在当前目录下产生了一个.Test.java.swp 文件,这个文件使用 ls 命令查看不能发现,使用 ls -a 命令查看可以知道 Test.java.swp 是一个隐藏文件。

在 linux 下用 vi 或 vim 打开 Test.java 文件时

[root@localhost tmp]# vi Test.java

出现了如下信息:


E325: ATTENTION  
  Found a swap file by the name ".Test.java.swp"  
    
       owned by: root   dated: Wed Dec  7 13:52:56 2011  
       file name: /var/tmp/Test.java  
       modified: YES  
       user name: root   host name: localhost  
       process ID: 26153 (still running)  
  While opening file "Test.java"  
         dated: Wed Dec  7 14:00:46 2011  
      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 Test.java"  
    to recover the changes (see ":help recovery").  
    If you did this already, delete the swap file ".Test.java.swp"  
    to avoid this message.  
  "Test.java" 11L, 237C  
  Press ENTER or type command to continue

原因是在此次 vi 或 vim 操作前有过一次使用 vi 或 vim 操作 Test.java 文件时出现了异常中断,所以在当前目录下产生了一个.Test.java.swp 文件,这个文件使用 ls 命令查看不能发现,使用 ls -a 命令查看可以知道 Test.java.swp 是一个隐藏文件。

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

想要不再有上面的警告提示,把该文件删除即可:

[root@localhost tmp]# rm .Test.java.swp
rm: remove regular file `.Test.java.swp'? y
[root@localhost tmp]#

使用 vi 或 vim 编辑其他文件出现类似情况的处理方法一样可以。

1

评论区