【发布时间】:2013-03-22 20:49:40
【问题描述】:
vim 的 system 函数的文档说明了第二个参数:
当给出 {input} 时,这个字符串被写入一个文件并作为标准输入传递给命令。
我的理解是,如果你的system 电话看起来像这样:
call system('node something.js --file', 'here is some text')
执行的命令如下所示:
node something.js --file some/temp/file
和some/temp/file 将文本here is some text 作为其内容。为了测试这一点,我运行了 vim 命令(第二行是结果):
:echo system('cat', 'here is some text')
here is some text
好的,看起来不错。第二次测试:
:echo system('echo', 'here is some text')
<blank line>
我没有得到一些临时文件的名称,而是得到了一个空行。此外,当我在 node.js 脚本中打印 process.argv 时,我只会得到 ['node', 'path/to/something.js', '--file']。
关于如何使用 {input} 参数,我缺少什么?为什么它似乎适用于 cat,但不适用于 echo 或我自己的脚本?
【问题讨论】:
-
嘿,投反对票的人。介意告诉我如何改进我的问题吗?
标签: vim vim-plugin