views:

37

answers:

1

I frequently search for a token, perhaps a function name, throughout my codebase. My traditional method would be to grep for the term itself. However, the codebase is so large that I can't do this efficiently (it takes minutes).

Is there a way to do this efficiently?

ack (which ignores irrelevent files such as revision control files) is still too slow. ctags only finds declarations, which isn't what I need. I thought something like strigi might work, but I haven't tried it.

I'm on linux, using vim and the GNU toolchain, on a largely C++ codebase.

+1  A: 

Use find and fgrep. A decent find will restrict the set to files matching some set of criteria, and fgrep will search within each file. Note that fgrep will be faster than grep.

You could also use an IDE's code indexing features. For example, Eclipse will allow you to go to a function's declaration, and it builds the relevant set in the background while you work. Even vim 7 has some such features, although I don't remember exactly what it does beyond code completion.

Borealid
Wow, fgrep is a lot faster than grep, like 6 times faster. That said, I'm really looking for some kind of indexing - I don't want to have to specify the file type (I'm working with C++, but found a token I was looking for in a .idl file).
Paul Biggar
@Paul Biggar: The equivalent of Spotlight for Linux is called Beagle. You could also use slocate or rlocate. rlocate might be better for this situation.
Borealid