vimtricks.wiki Concise Vim tricks, one at a time.

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

  • path is the list of directories Vim searches when you run :find, :sfind, or gf
  • . 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 :find gives 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 wildmenu for an interactive completion menu: set wildmenu
  • Exclude noisy directories from the search: set wildignore+=**/node_modules/**,**/.git/**
  • Use :sfind to open the file in a horizontal split instead
  • gf (go to file under cursor) also respects path, so it will find files in subdirectories too
  • For very large projects, ** can be slow — consider narrowing it with src/** instead of bare **

Next

How do I complete identifiers using ctags from within insert mode?