我正在尝试使用VIM+TMUX设置来在R中写
代码R.
看起来很简单,但我对VIM的变量或功能不了解,我对Tmux是新的。
通过一些研究,我找到了 tmux send-keys
命令,看起来很有希望,因此我目前能够映射
之类的内容:silite! tmux send -keys -t 0:0.0'print(“ test”)'enter
,这有效地运行了“ pand”命令“窗格” 0:0.0“同名易于参考)。不知道这是否有效,也不知道如何将'print()'
替换为某些编辑器的文本。
最终的目标是具有诸如< localleader> rr
之类的键键,以在r,< localleader> r [Motion]
运行运动和类似的东西中运行一行。运行选定的代码。
谢谢!
I am trying to use a vim+tmux setup to write code in R.
For that, I need to find a way to send lines (better if motions) to a terminal in other tmux pane (or section, if possible) which is running R.
Looks like a simple task, but I don't understand much about vim's variables or functions, and I'm new on tmux.
With some research, I found the tmux send-keys
command, which looks pretty promising, so I'm currently able to map something like
:silent ! tmux send-keys -t 0:0.0 'print("test")' Enter
and that effectively runs the "print" command in the pane "0:0.0" (I'm thinking in always open a section with the same name for easy of reference). No idea if that's efficient, and no idea about how to substitute the 'print()'
to some editor's text.
The final goal is to have keybindings like <localleader>rr
to run a line in R, <localleader>r[motion]
to run the motion, and something similar to run selected code.
Thanks!
发布评论
评论(2)
有点晚,但是您可以尝试插件 vimtux 。它允许您选择一个特定的TMUX窗格,您可以在其中使用(也)动作(例如
&lt; read&gt; rap
,&lt; rg&gt; rgg 等)。
A bit late, but you can try the plugin vimtux. It allows you to select a specific tmux pane, where you can send text to this tmux pane using (also) motions (e.g.
<leader>rap
,<leader>rgg
etc.).对 $ home/.vim/plugin )中
,在vim中,如果您键入
&lt; cc&gt;&gt;&gt;&lt; cc&gt;
,当前段落将被发送到窗格(假设vim
是使用textObjects
启用功能构建的)。在视觉模式下,将发送选定的文本。要仅发送当前行,您可以通过执行v&lt; cc&gt;&lt; cc&gt;
来使用线路视觉。 (vim
实际上没有对线路文本对象的内置支持,但是有可用的插件。)请注意,可以通过在运行中运行的过程中检查$ tmux_pane可以轻松确定目标窗格的正确值那个窗格。您可以使用
0:2.1
之类的特定目标,但是上面使用%1
作为默认值。这可能是一个不好的默认值。 YMMVWith some minor tweaks to slime.vim, you can do this by putting the following file in your vim plugin dir (eg
$HOME/.vim/plugin
)Now, in vim, if you type
<C-c><C-c>
, the current paragraph will be sent to the pane (assumingvim
was built with thetextobjects
feature enabled). In visual mode, the selected text will be sent. To send just the current line, you can use linewise-visual by doingV<C-c><C-c>
. (vim
doesn't really have builtin support for linewise text objects, but there are plugins available.)Note that the correct value for the target pane can easily be determined by inspecting $TMUX_PANE in the process running in that pane. You can use specific targets like
0:2.1
, but the above uses%1
as a default. This is probably a bad default to use. YMMV