I use Vim for coding for years, mostly with NerdTree to handle easily a big project with multiple files - like a MVC framework.
But i faced regulary a issue, how to find words, sentences, keywords in files into the project? All the files aren't open in buffers. I used to make it with this find & grep command in the terminal but it's need me to put vim in hte background, copy the name of the files and go back to vim.
find . -type f -name *.js -print0 | xargs -0 grep -i foo
Not really userfriendly...
Is there a better/faster way to do this ?
There are different ways to do that:
:vimgrep to do grepwith :vim or ack plugin, the found file path+name would be listed in quickfix list, to let you jump to easily.
also I have written a script to do "grep" again on quickfix list, may helpful too:
https://github.com/sk1418/QFGrep
You can run external commands using r:
:r! command-to-run
You could use your existing find command with this:
:r! find . -type f -name *.js -print0 | xargs -0 grep -i foo
The output of running this command will be inserted into your current buffer.
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