pholat
pholat

Reputation: 487

grep in with --include in project with wariable depth

I really like working with grep for it's robust work and customizability. :vimgrep is too slow for me, grep without --include (or --exclude) too. Also I work with at least 8 file types and --include is a huge helper.

My problem is that:

:grep "ILookForThat" **/*.{c,h}*

Search only one catalog depths, while I need at least four.

:grep -R "ILookForThat" --include=*.{c,h}*

Doesn't work ( the same with "*.{c,h}*" )

What I look for is answer: how to make grep (not vimgrep, ag, or anything else) work, or maybe some answer like: "That definitely should work".

I can add that I use 64 bit Ubuntu 16.04 LTS , removed my aliases for grep. Of course answers without quicklist are with no acceptance.

Upvotes: 0

Views: 153

Answers (2)

pholat
pholat

Reputation: 487

:grep -r --include=*.{c,h}* ILookForThat .
Everything works as designed, but grep used from within vim has to have a starting point which is stated with a dot character.

Upvotes: 2

Randy Morris
Randy Morris

Reputation: 40947

After some quick tests I think this should work for you but it's a little verbose:

:grep -r --include="*.c" --include="*.h" "ILookForThat" .

You could consider wrapping this in a custom :command if it's too verbose to be useful.

Upvotes: 2

Related Questions