我如何退出Vim,而不是:q,然后返回继续编辑?
当前回答
如果您正在使用Neovim,您可以执行以下操作:
:terminal命令打开终端窗口。 做好你的终端工作 输入exit终止终端进程 按任意键返回到Neovim
其他回答
您可以使用:sh退出到默认shell,然后在shell提示符下输入$ exit将返回到Vim。
有几种方法可以退出Vim,并且当您返回时一切都是一样的。在Vim本身中有非常好的文档解释了实现这一点的各种方法。您可以在vim中使用以下命令访问相关帮助页面
为了给你一个简单的总结,这里有不同的退出和返回的方法,而你的会话完好无损:
Suspend and resume - You don't actually quit Vim with this; you simply hide your session in the background until you need it. If you reset your computer or issue a kill command to Vim, you will lose your session. This is good for when you want to switch to another task temporarily, but if this is the case, then you might want to look into using the GNU Screen utility instead. Sessions - This is the true way of saving your session between instances of Vim. Even if you truly quit Vim, your session will be there for you when you return. This is probably what you are looking for.
假设终端Vim是*nix类型:
暂停运行Vim
Ctrl + Z
将暂停进程并返回到您的shell
fg
将恢复(带到前景)您暂停的Vim。
启动一个新的shell
使用以下命令启动子shell:
:sh
(由)
:set shell?
or
:!bash
紧随其后的是:
Ctrl+D(或退出,但为什么要输入这么多?)
杀死外壳并返回Vim。
只要输入fg,然后回到你最近暂停的程序。
你也可以通过:sus进入shell,然后通过fg返回。
如果您经常需要在shell和vim之间来回切换,那么您真正想要的可能是在shell中只有一个vim实例,并使用它来打开工作区中的任何文件。如果是,检查这个问题。一旦您正确地设置了它,您可以:sus或C-z返回到shell,然后只需v或v <newfile>返回到vim。
我的答案几乎就是我的日常生活。