从VIM庆典执行当前行 [英] Execute current line in bash from vim
问题描述
此问题是类似的Vim:执行当前文件,而是执行的电流?文件我想只执行当前行。
This question is similar to Vim: execute current file? but instead of executing the current file I want to execute only the current line.
这可能吗?
更新:理想情况下,我找它可以在外壳副作用的解决方案。
例如,假设我有以下行:
Update: Ideally, I am looking for solutions which can have side effects in the outer shell. For example, suppose I have the following line:
alias foo=bar
在vim运行命令,如果我开始与后壳:SH
,别名富
可用,但如果我不干 VIM
使用:q
,然后别名不再
After running the command in vim, if I start a shell with :sh
, the alias foo
is available, but if I quit vim
using :q
, then the alias is no longer available.
推荐答案
没问题,你可以写当前文件的任何内容到另一个程序的标准输入:
Sure thing, you can 'write' any content of the current file into the stdin of another program:
:.w !bash
下面。
(W前面的部分)是指你正在写行的范围和。
是仅当前行。然后,可以使用!庆典
来写那些行抨击。
Here .
(the part before w) refers to the range of lines you are writing, and .
is only the current line. Then you use !bash
to write those lines to bash.
这篇关于从VIM庆典执行当前行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!