VIM中是否有可能重复“执行并更新'# =>'标记”用于 ruby 代码的 TextMate 功能。
我想要这样的东西:
x = 2
class A
def a
42
end
end
x # =>
A.new.a # =>
输入一些命令...并获取
x = 2
class A
def a
42
end
end
x # => 2
A.new.a # => 42
这是来自 Ciarán Walsh 的博客:
另一个绝对值得了解的工具
是“执行并更新'# =>'
标记”命令(默认在 ⌃⇧⌘E 上)。
要使用它,请添加一些注释标记
(#⇥ 上有一个片段
为您插入这些)到末尾
您想查看的线路
结果然后触发
命令。 TextMate 将运行您的代码
并报告标记结果
行内联在评论中。这
该功能非常适合发布代码
在线,因为它显示了来源和
结果在一起。
Is there a possibility in VIM to repeat "Execute and Update '# =>' Markers" TextMate feature for ruby code.
I'd like to have something like:
x = 2
class A
def a
42
end
end
x # =>
A.new.a # =>
Enter some command... and get
x = 2
class A
def a
42
end
end
x # => 2
A.new.a # => 42
Here is a description of this feature from Ciarán Walsh’s Blog:
Another tool definitely worth knowing
is the "Execute and Update '# =>'
Markers" command (on ⌃⇧⌘E by default).
To use it, add some comment markers
(there is a snippet on #⇥ that will
insert these for you) to the end of
lines you would like to see the
results of and then trigger the
command. TextMate will run your code
and report the result of the marked
line inline in the comments. This
feature is great for code posted
online since it shows the source and
the results together.
发布评论
评论(2)
使用 rcodetools 中的
xmpfilter
。Use
xmpfilter
from rcodetools.看起来将其编写为 Vim 函数应该不会太难。试试这个:
然后
:调用 ExecuteAndUpdate()
。一个限制是它用标记对每一行进行两次评估。因此带有标记的线条不应该有副作用。
Seems like it shouldn't be too hard to write this as a Vim function. Try this:
Then
:call ExecuteAndUpdate()
.One limitation is that it evaluates each line with a marker twice. So lines with markers shouldn't have side-effects.