I couldn't really use the proposed solution because the shellescape return a string with simple quotes ' so I couldn't use it inside the --exclude grep opt; this is what I worked: let &grepprg="grep -n -r --exclude=\\*.{o,obj,~,pyc,git}\\* --exclude={tags,cscope}\\* $* /dev/null"