When using Vim, and given a directory filled with code (e.g. ~/trunk/) with a number of sub-directories, is there a way to grep/search for instances of text/regexes across the entire source code?
At the moment I use:
:lcd ~/trunk :grep "pattern" *.py */*.py */*/*.py */*/*/*.py
(Obviously I'm limiting this to Python files, which is a different issue, but it's noteworthy that ideally I'd like to limit the searches to files with specific extensions.)
From the root of your project, you can search through all your files recursively from the current directory like so: grep -R '. ad' . The -R flag is telling grep to search recursively.
:vimgrep "pattern" ~/trunk/**/*.py :copen 20
If you have quite a big project I'd recommend to you to use cscope and vim plugins. Here is one designed to handle big projects: SourceCodeObedience
There is a brief description of how to grep text using SourceCodeObedience.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With