"set working directory DIR
let DIR = expand("$HOME/Projects/tinyos")
"set the shortcut gr to search the current word under cursor in directory DIR
nnoremap gr :call Look_For_String()<CR><C-L>
function! Look_For_String()
exe "grep -R " . expand("<cword> ") . DIR
endfunction
A very simple code, but failed. Vim told me that DIR not defined. why?
]]>