linux下vi或vim編輯文件時提示Found a swap file by the name的原因及解決方法

在linux下用vi或vim打開test.java文件時

[root@Jenny test]# 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: Jenny  
       process ID: 7325 (still running)  
  While opening file "test.java"           dated: Sat Jan  16 11:28:46 2016        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@Jenny test]# rm .test.java.swp


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章