linux下使用vim打开文件时报如下异常
E325: ATTENTION
Found a swap file by the name ".jsidInspector.py.swp"
owned by: root dated: Thu Jan 12 11:36:47 2017
file name: /inspectoraccount/jsidInspector.py
modified: YES
user name: root host name: localhost.localdomain
process ID: 7084 (still running)
While opening file "jsidInspector.py"
dated: Thu Jan 12 13:24:22 2017
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 jsidInspector.py"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file ".jsidInspector.py.swp"
to avoid this message.
在vim格式未保存时退出,或者两台机器同时操作一个文件时都会出现这个问题(报存在一个swap文件) 如果是多台机器同时操作一个文件,直接在另外一台机器退出即可 如果是未保存退出导致的(比如突然强制关机),首先你可以按回车什么都不干,就直接进入到了当前的文件vim模式,看看当前的文件内容是不是原先的内容,如果觉得和你想要的差不多不需要恢复,那就直接执行rm指令删除那个swap文件
rm -rf .jsidInspector.py.swp
执行这个操作不会对你现在的文件产生影响。如果内容变化较大,你想要恢复,那就按
:q
先退出来,然后执行
vim -r jsidInspector.py
接着会出现要求你选择要恢复的指定文件,输入swap文件对应的数字,文件就恢复到了未保存时退出的样子。