vi 的 splitview 上的 Linux shell (bash)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3222974/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Linux shell (bash) on vi's splitview
提问by gc5
I've been searching with no results for an integration of bash inside vi, as featured in emacs; the problem is: I have vi open with 2 views, one open with :splitcommand, and I want to use bash through the second view, while I'm editing a file in the first; if I do :shwhile editing the second view, the whole session pauses and a bash shell is opened, but I'm not able to edit the file and use the shell at the same time..
I don't want to use !<command>or external programs such as "terminator".. Is there a solution?
Thx
我一直在寻找在 vi 中集成 bash 的结果,但没有结果,如 emacs 中的特色;问题是:我用 2 个视图打开 vi,一个用:split命令打开,我想通过第二个视图使用 bash,而我在第一个视图中编辑文件;如果我:sh在编辑第二个视图时这样做,整个会话会暂停并打开一个 bash shell,但我无法同时编辑文件和使用 shell.. 我不想使用!<command>或外部程序比如“终结者”..有解决办法吗?谢谢
回答by jabirali
Have you tried looking for third-party Vim plugins? Conque Shelllooks like it might do the job.
您是否尝试过寻找第三方 Vim 插件?Conque Shell看起来可以完成这项工作。
回答by Greg Sexton
I'm afraid this feature isn't available in (presumably) Vim. It is on the list of possible new features. See here http://www.vim.org/sponsor/vote_results.php. At the current time of writing this is feature number two, add IDE features. If you want to vote for this feature you will need to sponsor Vim.
恐怕这个功能在(大概)Vim 中不可用。它在可能的新功能列表中。见这里http://www.vim.org/sponsor/vote_results.php。在撰写本文时,这是第二个功能,添加 IDE 功能。如果你想为这个功能投票,你需要赞助 Vim。
回答by AL the X
I use VIM in conjunction with tmux, which handles window splits very well. I just transitioned to this workflow from a combination of terminal and GVIM, though, and I encountered your question in looking for a piece missing from my old workflow.
我将 VIM 与 tmux 结合使用,它可以很好地处理窗口拆分。不过,我刚刚从终端和 GVIM 的组合过渡到此工作流程,我在寻找旧工作流程中缺少的部分时遇到了您的问题。
I could run GVIM from the command line with the "--servername" flag and add files to that window with the "--remote-tab" flag. Now that I'm living entirely in the terminal with tmux, I don't seem to have the same option, so BBW. :/
我可以使用“--servername”标志从命令行运行 GVIM,并使用“--remote-tab”标志将文件添加到该窗口。现在我完全生活在终端和 tmux 中,我似乎没有相同的选择,所以 BBW。:/
回答by Thomas Baruchel
I just wrote myself a plugin for that purpose, see http://www.vim.org/scripts/script.php?script_id=4887
我只是为此目的给自己写了一个插件,请参阅http://www.vim.org/scripts/script.php?script_id=4887
It won't work under Windows. On the other hand, it uses the Unix philosophy: two FIFOs, some tricky interaction between background processes. It doesn't require python or whatever. It allows to execute either a shell or any interpreter for a programming language. You can see a video of it with GNU APL working in a buffer here.
它在 Windows 下不起作用。另一方面,它使用 Unix 哲学:两个 FIFO,后台进程之间的一些棘手的交互。它不需要python或其他任何东西。它允许为编程语言执行 shell 或任何解释器。您可以在此处观看 GNU APL 在缓冲区中工作的视频。
Like IPython, you work on your own buffer and see the output in a scratch buffer.
与 IPython 一样,您在自己的缓冲区上工作并在暂存缓冲区中查看输出。
Since I spent much time on Stackoverflow studying the answers of the three following pages:
由于我花了很多时间在 Stackoverflow 上研究以下三个页面的答案:
- Linux shell (bash) on vi's splitview
- How do I run a terminal inside of Vim?
- Vim: Run selected code in a persistent REPL-environment
I will post the same answer on the three pages; I hope nobody will be hurt by this triple post, but really they ask something close and someone else could find my answer interesting for his/her own purposes by browsing the web and finding any of these three pages.
我将在三页上发布相同的答案;我希望这个三重帖子不会伤害到任何人,但实际上他们问了一些接近的问题,其他人可以通过浏览网络并找到这三个页面中的任何一个来发现我的答案对他/她自己的目的很有趣。
回答by Thomas Baruchel
As a new (and maybe better) answer, may I suggest you to have a try to the amazing neovim fork of vim? It is a newer project; I tried it myself and found no compatibility issue with vim (including the use of sophisticated plugins) and it has exactly what you are asking for.
作为一个新的(也许更好的)答案,我可以建议您尝试一下令人惊叹的 vim 的 Neovim 分支吗?这是一个较新的项目;我自己尝试过,没有发现与 vim 的兼容性问题(包括使用复杂的插件),它完全符合您的要求。

