nol*_*eti 70
您可以向 vim 发送 SIGTSTP 信号。您可以通过按ctrl+ 来执行此操作z。Vim 将在后台暂停,您可以使用终端。键入fg终端恢复与VIM。
额外提示:这适用于几乎所有终端应用程序。使用bg以使应用程序在后台继续运行。
小智 35
在 vim 中,只需键入:
:!sh
Run Code Online (Sandbox Code Playgroud)
:!启动一个外部进程——在本例中sh是另一个 shell。退出外壳后,控制权将返回给 vim。如果你想和 vim 同时使用 shell &,在 sh 命令的末尾添加:
:!sh&
Run Code Online (Sandbox Code Playgroud)
evi*_*oup 21
您可以使用该:shell命令(或简称:sh)。来自:help :shell:
这个命令启动一个shell。当 shell 退出时(在“exit”命令之后)你返回到 Vim。shell 命令的名称来自 'shell' 选项。
默认情况下,在 Ubuntu 上,这会给你 bash。完成后键入exit以返回vim。
小智 9
从最近的 vim 开始,您现在可以执行以下操作:
:terminal
Run Code Online (Sandbox Code Playgroud)
这最初是在 Vim 8.0.693 中添加的,但有很多错误。见:help terminal:
WARNING: THIS IS ONLY PARTLY IMPLEMENTED, ANYTHING CAN STILL CHANGE
The terminal feature is optional, use this to check if your Vim has it:
echo has('terminal')
If the result is "1" you have it.
[...]
The terminal feature requires the +multi_byte, +job and +channel features.
==============================================================================
1. Basic use terminal-use
This feature is for running a terminal emulator in a Vim window. A job can be
started connected to the terminal emulator. For example, to run a shell:
:term bash
Or to run a debugger:
:term gdb vim
The job runs asynchronously from Vim, the window will be updated to show
output from the job, also while editing in any other window.
Run Code Online (Sandbox Code Playgroud)
作为所有答案的补充。
您可以安装ConqueTerm 插件
这个插件提供了在 vim 缓冲区内运行交互式程序的能力。
安装后,您可以将此 2 行添加到您的.vimrc:
:nnoremap <S-w> :q!<CR>
:nnoremap <S-t> :ConqueTermSplit bash<CR>
Run Code Online (Sandbox Code Playgroud)
而你,也就能够运行bash按Shift+ T,并关闭当前标签Conque按Shift+W
如果您需要快速打开/关闭,这是完美的bash。
这是gif显示它的样子