I'd like to define a custom command for doing the following steps: grep the current word, copen, incremental search the grep'ed word. Here's the command I'm using:
nmap <C-p> :execute "grep! -Irn " . shellescape(expand("<cword>")) . " ."<cr>:copen<cr>:g/<cword>/<cr>
But the second cword is expanded to the current word after the quickfix window is opened. How can I use the word that's used by grep earlier?