[英]Perform a command in another shell from Vim
I use two monitors in my development workflow, one is a fullscreen vim session for editing and the other is a fullscreen terminal where I run make && ./test
to show results. 我在开发工作流程中使用了两个监视器,一个监视器是用于编辑的全屏vim会话,另一个是我运行
make && ./test
来显示结果的全屏终端。 Fairly often I find myself opening a bunch of other windows in the background (browers, more shells etc). 通常,我经常发现自己在后台打开了一堆其他窗口(吹风机,更多贝壳等)。 I don't like this for a few reasons:
我不喜欢这样做有几个原因:
:w alt-tab up-arrow enter alt-tab
is far too many keystrokes. :w alt-tab up-arrow enter alt-tab
太多了。 I think a good solution might be to have a vim command that runs make && ./test
in the other window, but I can't think of how to do this. 我认为一个好的解决方案可能是在另一个窗口中运行一个运行
make && ./test
的vim命令,但是我不知道该怎么做。 I could write a server/client script that waits from some notification from vim then runs the command but it really seems like there should be a simpler solution. 我可以编写一个服务器/客户端脚本,等待来自vim的通知,然后运行命令,但实际上似乎应该有一个更简单的解决方案。 Any thoughts?
有什么想法吗?
Thanks to Jim's comment for getting me started. 感谢吉姆的评论让我入门。 This is what I'm doing now:
这就是我现在正在做的:
On the first monitor: tmux new-session -s dev
(creates a new tmux session named dev) 在第一个监视器上:
tmux new-session -s dev
(创建一个名为dev的新tmux会话)
On the second monitor: tmux new -t dev
(connects to that new session) 在第二个监视器上:
tmux new -t dev
(连接到该新会话)
On the second monitor: Ctrl-b + c
(creates a new window) 在第二个监视器上:
Ctrl-b + c
(创建一个新窗口)
I forked vimux and wrote functions to send commands to another window. 我分叉了vimux,并编写了将命令发送到另一个窗口的函数。 So now in vim I can use
:call VimuxRunCommandWin("make && ./test")
. 所以现在在vim中,我可以使用
:call VimuxRunCommandWin("make && ./test")
。
And I think that's probably enough procrastination for one day... 我认为这可能足以拖延一天的时间...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.