loading multiple files that match a string with vim
loading multiple files that match a string with vim using command line unix tools
Using the ever useful grep, with -l option, it outputs only the matching filenames:
grep -rl --exclude '*.svn*' CMFCore *
vim loads multiples file in one line separated by spaces. So I need to join the multiple lines into one, separated by space. Here we have the paste command. For each line, put a space as the separator:
paste -s -d " "
Finally I wanted vim to load this in GUI mode with tabs, so we put it together:
gvim -p $(grep -rl --exclude '*.svn*' CMFCore * | paste -s -d " " -)
- the part inside the $( ) is the output of the command.
- using pipes | the output of grep (the list of files) is read by paste
- the - in paste is telling it to input the stdout output of grep
I then quickly have my editor setup for work,

