在vim中,如何设置“args”到“grep -l”的结果 [英] in vim, how to set "args" to the result of a "grep -l"?

查看:261
本文介绍了在vim中,如何设置“args”到“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

: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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆