How do I open any file in a project by partial name without a fuzzy finder plugin in Vim?
Answer
:find **/*.py
Explanation
Vim's built-in :find command supports recursive glob patterns, making it possible to locate and open files anywhere in a project without installing a fuzzy finder plugin. Using ** as a directory glob wildcard, you can search across all subdirectories from the current working directory.
How it works
:findsearches for files matching the given pattern, using wildcard expansion**matches any number of directories recursively (zero or more levels deep)*.py(or any extension) matches any filename with that suffix- Pressing
<Tab>after the pattern cycles through all matches interactively
Example
To find and open any Python file named models.py anywhere in the project:
:find **/models.py
Press <Tab> to cycle through matches. To browse all Python files:
:find **/*.py
Then type the beginning of the filename and press <Tab> to filter.
Tips
- Add
set path+=**to yourvimrcto also make:find {name}(without globs) search recursively — then just:find models<Tab>works - Pair with
set wildmenufor a visual completion menu above the command line :sfind **/*.pyopens the file in a horizontal split;:vert sfindfor a vertical split- Combine with
set wildignore+=*/node_modules/*,*.pycto exclude unwanted files from completion