5zmzkg
Last Updated: February 25, 2016
·
533
· rbika

Open in vim all files returned by a grep search

To find all files in the current directory which their contents matches the pattern "foo", you can run

grep -rl foo *

If, in addition, you want to edit all files found by the previous command. you can use nested commands to directly open them in vim with the following command:

vim $(grep -rl foo *)

Alternatively, if you use GVim or MacVim you can open the files in tabs:

gvim -p $(grep -rl foo *)

or

mvim -p $(grep -rl foo *)