I want to have a function that vimgrep for the word under the cursor appended to a predefined string.I have defined this command:command! -nargs=0 GJL vimgrep <cword> *.tex | copenwhich does the job for only the current word. Now I want to grep for ref{ + <cword>. That is, in the case that <cword> is eqn1, I want to grep for ref{eqn1.Any idea how to set up this function in a .vimrc?
join string and  for vimgrep in command
vimrc;functions;vimgrep
Use exec with string concatenation:command! -nargs=0 GJL exec 'vimgrep ref{'.expand('<cword>').' *.tex | copen'In a function, you'd do something similar, but more neatly, I suppose:function Foo()    let l:pattern = 'ref{' . expand('<cword>')    exec 'vimgrep' l:pattern '*.tex | copen'endfunction