In a shell I use the following function to create a filelist and pass it to vim.
Feels alright, but I lost the line reference, I open the files in correct order but then I have to search again for the text as the cursor starts at first line.
Actual function on ~/.bashrc
function vimgrep(){
vim `grep -IR "$1" * | awk -F: '$1!=f{print ""$1"";f=$1}' | grep -v 'Test\|test'` +ls
}
function vimgrep2(){
vim `grep -IR "$1" * | awk -F: '$1!=f{print ""$1"";f=$1}' ` +ls
}
Obs.: filelist must come from shell to vim, and then it must keep the line reference of the buffered files, just like with the results of :make when it catches any error (but without the bottom window [:cwindow]).
edited:
Ok… not so elegant, but I could pass the searched string to vim as +/”$1″, like:
vim `grep -IR "$1" * | awk -F: '$1!=f{print ""$1"";f=$1}' ` +/"$1"
Would be better if the script doesn’t use a temporary file.
Vim also comes with a
vimgrepcommand you could useBe careful of running it in a directory with a lot of files below it.