在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