Why do they use the double asterisk?
I've read Vim's help on vimgrep
, I've looked around on stack overflow and vimcasts and whilst I have found lots of people saying that this is how you search recursively in current directory, I haven't found an explanation as to why.
Lets use an example to make it easier to explain. If I wanted to find all occurrences of foo in my current directory and down, I could use
:vim[grep][!] /{pattern}/[g][j] {file}
so that becomes
:vimgrep /foo/ **/*
So looking at the {file}
part of this grep:
- I understand that it is a file path.
- I understand that an asterisk (
*
) is a wildcard. - I understand that the forward-slash acts as a directory separator.
My specific question is why it comes in the format of
**/*
and not
*/*
I've tried searching using / in a few different cases and that seems to search any file in any directory exactly 1 deep from my current directory, which I assume is why double asterisk is used.
ie Why is it a double asterisk? Does this indicate "I want you to search recursively" through some clever mechanisms I don't fully understand or is this just simply a keyword that serves to say 'search recursively'? Am I completely off and this is not an inbuilt part of vim but a part of the shell? (these parts are not my actual question but rather serve to give understanding as to what I am confused about, my actual question is above).
If there are any ways I can improve my question, please let me know, it's my first time asking.
**
has been in Vim since 2005 whereas bash has it since 2009. – Camilia