I am trying to replicate Notepad++ find in all files in GVim on windows. I found the following script for vimgrep which seems to find the word under the cursor in directories
map <F4> :execute "vimgrep /" . expand("<cword>") . "/j /**/*.c " <Bar> cw<CR>
I modified it to search always in a the root directory of my project. But it is not working. The project is under "c:\lion"
map < F4> :execute "vimgrep /" . expand("<cword>") . "/j {c:\lion\}/**/*.c " <Bar> cw<CR>
The following error is shown.
"{c:" Illegal file name
Cannot open file "{c:"
Drop the
{...}, and just insert the path as-is, like you would on the command-line (a mapping is nothing more than a recorded macro). It's easier to use forward slashes; these work on Windows, too.Maybe you've been confused by the
:execute. There's another way (withc_CTRL-R_CTRL-W) to insert the current word, which avoids this:Also, you should use
:noremap; it makes the mapping immune to remapping and recursion.