vim編輯文件警告Swap file already exists,如何刪除vim編輯產生的.swp文件?查看隱藏文件命令
Linux(centos7)下多個用戶同時編輯一個文件,或編輯時非正常關閉,再下次編輯打開文件時均為顯示如下警告信息:
E325: ATTENTION
Found a swap file by the name ".other.conf.swp"
owned by: root dated: Wed Nov 29 02:23:20 2017
file name: /usr/local/nginx/conf/other.conf
modified: YES
user name: root host name: host.localdomain
process ID: 19783 (still running)
While opening file "other.conf"
dated: Wed Nov 29 02:28:57 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 other.conf"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file ".other.conf.swp"
to avoid this message.
Swap file ".other.conf.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:
-----------------------------
使用命令查看隱藏swp文件(隱藏文件都以.開頭):
ls -a
查看當前目錄下與打開的文件同名的.swp文件,如.other.conf顯示為.other.conf.swp
使用rm -rf刪除這個.swp文件,當再打開test.xml文件時,便不會彈出警告信息。
# rm -rf .other.conf.swp