解決Swap file ".ceshi.c.swp" already exists!問題

關於swp文件:使用vi,經常可以看到swp這個文件,那這個文件是怎麼產生的呢,當你打開一個文件,vi就會生成這麼一個.(filename)swp文件以備不測,如果你正常退出,那麼這個.(filename)swp文件將會自動刪除。
因此.(filename)swp文件就是你沒有正常退出vi或者vim編輯器時留下來的!比如:強行關閉vi或vim時,電源突然斷掉,或者你使用了Ctrl-zz。(正常的退出方式應該是Shift-ZZ)
這時候就會出現下面的情況了
<span style="font-family:SimSun;color:#ffffff;background-color: rgb(0, 0, 0);">E325: ATTENTION
Found a swap file by the name ".ceshi.c.swp"
          owned by: root   dated: Sat Jul  4 19:51:46 2015
         file name: /c/ceshi.c
          modified: YES
         user name: root   host name: c66-WR
        process ID: 2801
While opening file "ceshi.c"
             dated: Sun Jul  5 12:38:54 2015
      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 ceshi.c"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file ".ceshi.c.swp"
    to avoid this message.

Swap file ".ceshi.c.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit:</span>


重點:解決辦法

  用下面的命令刪除swp文件

    rm .{your file name}.swp

    例如:我的文件名是ceshi.c 那麼就用這樣的命令:rm .ceshi.c.swp (當然你前面也可以加-rf強制刪除)


問: (vi 一個文件時怎麼樣可以不讓它產生.swp文件?或不讓他提示【“Swap file ".文件名.swp" already exists![O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit:】)

處理方法: 打開 vi /etc/vimrc 並在末尾添加 set noswapfile 後保存退出 OK



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