非正常關閉vim編輯器后提示錯誤的解決方法


使用vim,錯誤出現原因一般為以下兩種情況:

(1)    當你用多個程序編輯同一個文件時。

(2)    非常規退出時。

會提示以下信息:

E325: ATTENTION
Found a swap file by the name".old.txt.swp"
         owned by: root   dated: Tue Mar 2813:27:34 2017
        file name: /tmp/old.txt
         modified: YES
        user name: root   host name:oldboy38
       process ID: 6855
While opening file "old.txt"
             dated: Tue Mar 28 13:27:10 2017
 
(1) Another program may be editing thesame 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 filecrashed.
   If this is the case, use ":recover" or "vim -rold.txt"
   to recover the changes (see ":help recovery").
   If you did this already, delete the swap file ".old.txt.swp"
   to avoid this message.
Swap file ".old.txt.swp"already exists!
[O]penRead-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:
(1)(2)為官方給出的解決方法:

(1)    為了避免同一個文件產生兩個不同的版本,還是建議選擇"(Q)uit"或者繼續謹慎修改選擇"(E)dit anyway"。

(2)    也可以選擇"(R)ecover"或"vim -r filename"恢復到未修改之前,然后再把swp文件刪除(這個時候要確保你的swp文件沒有用處了)。

最下面選項的意思:

O:  只讀,不能改

E:  可以改,從前的修改都丟失

R:  恢復(從前的修改)

D:  刪去(刪去.swp文件,文件恢復到未修改前)

Q:  退出

A:  放棄

 具體解決方案:

(1)    不想保留原先修改的內容直接選D就可以。

(2)    想保留原先修改的內容選R把修改的內容復制出來保存,再退出文件刪除awp文件。(awp文件默認為隱藏文件,用ls -a命令查看,用rm命令刪除。)



非正常關閉vim編輯器后提示錯誤的解決方法

標簽:vim 錯誤

原文:http://hellhappy.blog.51cto.com/12553462/1911083

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM