vim中恢复ctrl+z

就在刚才vim下编辑一个文本本来想按下shift+zz来保存文本并退出vim,没想到又按成了ctrl+z,之前不了解状况的我,以为保存了,但是再次用vim打开这个文本的时候,发现vim保存了一个对应的swp文件,总会出现下面的提示,我这次忍无可忍了,就搜索了解了一下。

E325: ATTENTION
Found a swap file by the name ".vimrc.swp"
          owned by: smslit   dated: Fri Jan 13 10:27:11 2017
         file name: ~smslit/.vimrc
          modified: no
         user name: smslit   host name: tianyes-Mac-mini.local
        process ID: 1110 (still running)
While opening file ".vimrc"
             dated: Sun Nov 27 16:58:29 2016

(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 .vimrc"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file ".vimrc.swp"
    to avoid this message.

Swap file ".vimrc.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:

原来是因为把编辑这个文件的vim推到了后台,其实按下ctrl+z后会有提示如下,但之前不知道咋回事儿,其实仔细想想,好像有个很好的朋友告诉过我这个,汗,记性变差好严重!

➜  ~ vim .vimrc

[1]  + 1110 suspended  vim .vimrc

解决办法很简单,可以先查看一下后台有啥:

➜  ~ jobs
[1]  + suspended  vim .vimrc

然后执行fg,就能跳回编辑文件的vim了:

➜  ~ fg
[1]  + 1110 continued  vim .vimrc

为此做了动态图片可以看清操作流程:

vimCtrlZ


vim

436 字

2017-01-13 01:37 +0000