# vimgrep can not find a pattern in specified directory

I have encountered very strange problem using vimgrep command. I try to find a match in all the files in all subdirs of a specified directory:

:vimgrep /word_I_search/ path\to\my\dir\**\*


(there are backslashes in path because I am on Windows). Command reports:

E480: No match: word_I_search


But I know there are matches! And if I do not search in subdirs or if I start searching one level higher everything is ok. Following commands successfully find what I want:

:vimgrep /word_I_search/ path\to\my\dir\*
:vimgrep /word_I_search/ path\to\my\**\*


I have never encountered this problem on my Linux machine and do not know where to start troubleshooting it. Any ideas? Please help.

UPDATE:

command works as expected if I use less backslashes. Following commands work as expected:

:vimgrep /word_I_search/ path/to/my/dir/**/*
:vimgrep /word_I_search/ path\to\my\dir\**/*

• You don't need to use backslashes. – romainl Aug 18 '16 at 8:05
• Thanks, @romani! The problem is that slashes are automatically replaced by backslashes when I press <tab> to autocomplete path. But looks like I found workaround. – lesnik Aug 18 '16 at 8:11

** matches only directories as you can read in http://vimdoc.sourceforge.net/htmldoc/editing.html#file-searching, but obviously at least 1 subdirectory if you are using backslashes in your path. I.e. ** matches not 0..n but 1..n subdirectories. (Again) this is true only when you are using backslashes in your search path.
• I think in the context of vimgrep this is not true. See the linked documentation. It talks about a few functionalities and adds: "Other commands use |wildcards| which is slightly different.". Also: I couldn't reproduce the problem on Windows7 with Vim 8.1.751. – Ralf Jan 18 at 15:36
• I wrote obviously in the anser above because I could reproduce this issue on Win10 with a x64 build of Vim 8.0 (2016 Sep 12). After some testing, I concluded that it matters if you use forward- or backslashes and if you use \, vimgrep needs to match at least one subdirectory. – salchint Jan 18 at 15:48
 :vimgrep /text/ path_to_dir/* path_to_dir/**/*