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 *)
Written by Rafael Bika
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#