
十里(5km)工具
vim中恢复ctrl+z
本想按 shift+zz 保存退出 vim,结果手滑按成了 ctrl+z,之后每次打开文件都弹出 swap 文件的 E325 警告。这篇弄清了 ctrl+z 只是把 vim 挂到后台,用 fg 就能回来,以及如何恢复或删除 swp 文件。
0次点击1分钟阅读
就在刚才vim下编辑一个文本本来想按下 shift+zz 来保存文本并退出vim,没想到又按成了 ctrl+z,之前不了解状况的我,以为保存了,但是再次用vim打开这个文本的时候,发现vim保存了一个对应的swp文件,总会出现下面的提示,我这次忍无可忍了,就搜索了解了一下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21E325: 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 后会有提示如下,但之前不知道咋回事儿,其实仔细想想,好像有个很好的朋友告诉过我这个,汗,记性变差好严重!
1 2 3➜ ~ vim .vimrc [1] + 1110 suspended vim .vimrc
解决办法很简单,可以先查看一下后台有啥:
1 2➜ ~ jobs [1] + suspended vim .vimrc
然后执行fg,就能跳回编辑文件的vim了:
1 2➜ ~ fg [1] + 1110 continued vim .vimrc
为此做了动态图片可以看清操作流程:



