在vim中,如何设置“args”到“grep -l”的结果 [英] in vim, how to set "args" to the result of a "grep -l"?
问题描述
为了说明,以下是如何从命令行执行此操作:
To illustrate, here's how to do it from the command-line:
vim `grep "hello" * -Rl`
这会打开带有所有hello文件的vim文件单独)。我想做同样的事情,但从内部vim。在概念上,这样的东西(这不工作):
This opens vim with all the files that have "hello" in them (-l gives the filenames alone). I want to do the same thing, but from within vim. Conceptually, something like this (which doesn't work):
:args !grep "hello" * -Rl
我有完全不同的方法来实现这一点;
I'm open to completely different approaches to achieve this; I'd just like it to be on one line (so it's easy to edit and redo).
答案是: 在 hello $ c $之后,以下内容不适用于我c>:
:args `grep "hello" * -Rl`
但是,如果我删除它们或转义引号,它会工作:
But it works if I remove them or escape the quotes:
:args `grep hello * -Rl`
:args `grep \"hello\" * -Rl`
(这是埋在混乱的回答后的意见 - 我添加他们在这里,使他们更加明显,万一任何人有这个问题)
(this was buried in the comments after chaos' answer - I added them here to make them more visible, in case anyone else had this problem)
推荐答案
好,这对我有用:
:args `grep -Rl "hello" *`
运行vim 7.0.305。
Running vim 7.0.305.
这篇关于在vim中,如何设置“args”到“grep -l”的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!