Here's a hack from a vim newbie that seems to work:
function! SearchFunc()
let l:filenames = substitute(glob("*.c") . glob("*.cpp") . glob("*.h"), '\n', ' ', 'g')
try
execute 'vimgrep /^\s*\(struct\|class\)\s*' . expand("<cword>") . '/ ' . l:filenames
catch
echon 'No results found.'
sleep 800m
endtry
endfunction
nmap <Leader>fi :call SearchFunc()^M
This is necessary to search for a word under the cursor when entering \ fi.
Code Explanation:
vimgrep , , , try/catch/endtry. , , , , , .
"nmap" " ", - . , . Ctrl-V, Ctrl-M , ^ M, .
, , :
function! SearchFunc(findme)
let l:filenames = substitute(glob("*.c") . glob("*.cpp") . glob("*.h"), '\n', ' ', 'g')
try
execute 'vimgrep /^\s*\(struct\|class\)\s*' . a:findme . '/ ' . l:filenames
catch
echon 'No results found.'
sleep 800m
endtry
endfunction
,
:call SearchFunc('foo')
<cword> .