How do I open files in subdirectories without a fuzzy finder plugin?
Answer
:set path+=**
Explanation
Adding ** to Vim's path option turns the built-in :find command into a recursive file finder with tab-completion — no plugins required. Once set, you can type :find filename<Tab> and Vim searches all subdirectories from the current working directory.
How it works
pathis the list of directories Vim searches when you run:find,:sfind, orgf.means the current file's directory, and `` (empty entry) means the current working directory**is a glob wildcard meaning "search recursively through all subdirectories"- Combining
:set path+=**with:findgives you fuzzy-style tab-completion across your project tree
:set path+=** " usually in vimrc
:find utils<Tab> " lists all files named utils.* anywhere in the tree
Example
In a project with the structure:
project/
src/utils.go
internal/helpers/util.go
cmd/app/main.go
With path+=**:
:find util<Tab> → shows utils.go and util.go as completions
:find main<Tab> → opens cmd/app/main.go directly
Tips
- Combine with
wildmenufor an interactive completion menu:set wildmenu - Exclude noisy directories from the search:
set wildignore+=**/node_modules/**,**/.git/** - Use
:sfindto open the file in a horizontal split instead gf(go to file under cursor) also respectspath, so it will find files in subdirectories too- For very large projects,
**can be slow — consider narrowing it withsrc/**instead of bare**