从 vim 将输入发送到屏幕窗口
我设置了一个 vim 函数,可以突出显示一行文本并在 clojure 中执行。这是这个函数:
function! Clojure_execline()
let cl = (getline(line(".")))
// ...
exec 'clojure -e "' . cl . '"'
endfunction
这个函数的问题是启动速度很慢,而且因为每次运行它时它都会生成一个新的 clojure 会话,所以我无法调用之前运行的函数。理想情况下,我希望运行一个隐藏的 repl,在那里我可以从 vim 发送输入并检索输出。我了解了 gnu screen 并认为它可以帮助我,但我不知道如何将输入从一个屏幕窗口发送到另一个屏幕窗口。
为了澄清我的问题,请使用 clojure 的这一行:
(defn add2 [x y] (+ x y))
我希望能够在 vim 中突出显示这一行并在正在运行的 repl 中执行。我希望能够调用下面的行并让它在同一个 repl 中执行:
(add2 4 5)
然后,我希望能够获得该函数的输出。
所以,基本上,我的问题是,如何将输入从一个屏幕窗口发送到另一个屏幕窗口?
I have a vim function set up where I can highlight a line of text and execute in clojure. Here's the function:
function! Clojure_execline()
let cl = (getline(line(".")))
// ...
exec 'clojure -e "' . cl . '"'
endfunction
The problem with this is that it's slow to start and because it spawns a new clojure session every time I run it, I can't call a function I ran previously. Ideally, I'd like for a hidden repl to be running where I could send input from vim and retrieve the output from as well. I learned about gnu screen and thought it could help me, but I don't know how to send input from one screen window to another.
To clarify my problem, take this line of clojure:
(defn add2 [x y] (+ x y))
I'd like to be able to highlight this line in vim and execute in a running repl. I want to be able to call the line below and have it execute in the same repl:
(add2 4 5)
Afterwards, I'd like to be able to get the output of the function.
So, basically, my question is, how do I send input from one screen window to another?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
杰克·麦克拉里的建议是一个很好的建议。还有一些其他脚本可用,可能基于相同的想法:
VimClojure,它表示它确实“在 vim 缓冲区中进行复制”
和
slimv,特别支持 Clojure
和
Gorilla,我认为上面的 VimClojure 是基于 Gorilla 的,
我不知道 VimClojure 是否真的做了你想要的,将结果从屏幕发送回 Vim 中的缓冲区。我认为,一种方法是使用 Vim 的客户端-服务器功能来进行一些操作,可以使用 --remote-send 标志。看:
Jake McCrary's suggestion is a good one. There are also a couple other scripts available, probably based on same idea:
VimClojure, which says it does "repl in a vim buffer"
and
slimv, specifically supports Clojure
and
Gorilla, I think VimClojure, above, is based on Gorilla
I don't know whether VimClojure actually does what you want, sending result back from Screen to buffer in Vim. One way to do that, I think, would be to finagle something using Vim's client-server functionality, possible with the --remote-send flag. See:
我没有确切的答案,但也许值得看看 slime.vim 并看看是否可以从中学到什么。
有关它的博客文章
vim.org 上的脚本
I don't have an exact answer, but it might be worth taking a look at slime.vim and seeing if anything can be learned from it.
blog post about it
script at vim.org
找到了我要找的东西。您可以从终端执行此命令,将字符串直接发送到屏幕窗口的标准输入:
Found what I was looking for. You can execute this from a terminal to send a string directly to the stdin of a screen window:
您可能还对 Conque http://code.google.com/p/conque/
我将它用于 Scala
You might also be interested in Conque http://code.google.com/p/conque/
I use it for Scala