如何在Vim内部运行终端?

本文翻译自:How do I run a terminal inside of Vim?

I am used to Emacs, but I am trying out Vim to see which one I like better. 我已经习惯了Emacs,但是我正在尝试Vim,看看我更喜欢哪一个。

One thing that I like about Emacs is the ability to run a terminal inside Emacs. 我喜欢Emacs的一件事是能够在Emacs中运行终端。 Is this possible inside of Vim? 这可能在Vim内部吗? I know that you can execute commands from Vim, but I would like to be able to run a terminal inside of a tab. 我知道您可以从Vim执行命令,但是我希望能够在选项卡中运行终端。


#1楼

参考:https://stackoom.com/question/5bGz/如何在Vim内部运行终端


#2楼

No, you cannot: 你不能:

http://vimdoc.sourceforge.net/htmldoc/tips.html#shell-window http://vimdoc.sourceforge.net/htmldoc/tips.html#shell-window


#3楼

我知道的唯一方法是使用vim-shell ,即第三方补丁。


#4楼

I'm not sure exactly what you're trying to achieve (I've never used Emacs), but you can run commands in Vim by typing: 我不确定您要实现的目标(我从未使用过Emacs),但是您可以通过输入以下内容在Vim中运行命令:

:! somecommand [ENTER]

And if you want to type in several commands, or play around in a shell for a while, you can always use: 而且,如果您要键入多个命令或在shell中玩一会儿,则可以始终使用:

:! bash (or your favourite shell) [ENTER]

Once the command or shell terminates, you'll be given the option to press Enter to return to your editor window 一旦命令或外壳终止,您将可以选择按Enter键返回到编辑器窗口

Vim is intentionally lightweight and lacking in the ability to do non-editorish type things, just as running a full-blown shell inside a Vim pane/tab, but as mentioned above there are third-party addons such as vim-shell that allow you to do that sort of thing. Vim故意是轻量级的,并且缺乏执行非编辑类型的功能的能力,就像在Vim窗格/选项卡中运行成熟的Shell一样,但是如上所述,第三方插件(例如vim-shell)使您可以去做那种事情。

Typically if I want to switch between Vim and my shell (Bash), I just hit CTRL + Z to pause the Vim process, play around in my shell, then type 'fg' when I want to go back to Vim - keeping my editor and my shell nice and separate. 通常,如果我想在Vim和我的shell(Bash)之间切换,我只需按CTRL + Z即可暂停Vim进程,在我的shell中玩耍,然后在我想回到Vim时键入'fg'-保持我的编辑器和我的外壳很好,分开。


#5楼

I would definitely recommend screen for something like this. 我绝对会推荐类似这样的screen Vim is a text editor, not a shell. Vim是文本编辑器,而不是外壳。

I would use Ctrl+A S to split the current window horizontally, or in Ubuntu's screen and other patched versions, you can use Ctrl+A | 我可以使用Ctrl + A S来水平拆分当前窗口,或者在Ubuntu屏幕和其他修补版本中,可以使用Ctrl + A | (pipe) to split vertically. (管道)垂直拆分。 Then use Ctrl+A Tab (or equivalently on some systems, Ctrl+A Ctrl+I which may be easier to type) to switch between the windows. 然后使用Ctrl + A Tab (或在某些系统上等效的Ctrl + A Ctrl + I ,可能更容易键入)在窗口之间切换。 There are other commands to change the size and arrangement of the windows. 还有其他命令可以更改窗口的大小和排列。

Or a less advanced use of screen is just to open multiple full-screen windows and toggle between them. 或使用不太高级的screen只是打开多个全屏窗口并在它们之间切换。 This is what I normally do, I only use the split screen feature occasionally. 这是我通常所做的,我偶尔仅使用分屏功能。

The GNU Screen Survival Guide question has a number of good tips if you're unfamiliar with its use. 如果您不熟悉GNU Screen Survival Guide的用法,则可以找到许多很好的提示。


#6楼

You might want to take a look at the :sh command (see :help sh in Vim). 您可能需要看一下:sh命令(请参见Vim中的:help sh )。

Various commands 各种命令

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值