在使用vim編輯檔案過程中,因為斷網導致遠程登陸伺服器失敗。網路連接恢複後,再次登陸伺服器,vi開啟檔案,警示,提示資訊如下:
E325: ATTENTION
Found a swap file by the name ".cpu.sh.swp"
owned by: work dated: Fri Nov 23 11:17:23 2012
file name: ~work/fanbo/server/dialogue/cpu.sh
modified: YES
user name: work host name: db-testing-ps6056.db01.baidu.com
process ID: 16358
While opening file "cpu.sh"
dated: Fri Nov 23 16:35:41 2012
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 cpu.sh"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file ".cpu.sh.swp"
to avoid this message.
Swap file ".cpu.sh.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort, (D)elete it:
原因分析,因為在編輯過程中會產生緩衝檔案,如果沒有執行":w",而因為網路連接斷開,會在目前的目錄下產生一個以檔案名稱swp結尾的隱藏檔案。刪除這個檔案,再次用vi開啟就不會警示,但檔案會復原到編輯前的狀態。