我如何退出Vim,而不是:q,然后返回继续编辑?


当前回答

如果你不介意用一下鼠标:

启动你的终端, 选择一个文件, 选择打开标签。

这将在终端上创建一个新选项卡,您可以在该选项卡上运行Vim。现在使用鼠标移到/移出终端。我更喜欢这样,而不是总是必须键入(:shell和退出)。

其他回答

您可以使用:sh退出到默认shell,然后在shell提示符下输入$ exit将返回到Vim。

你可以通过以下方法暂时切换到shell模式:

:! <command>

:! ls

要扩展用户Zen的回答,可以在~/中添加以下行。vimrc文件允许在Bash和Vim之间快速切换:

noremap <C-d> :sh<cr>

只要输入fg,然后回到你最近暂停的程序。

有几种方法可以退出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.