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

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

  • :find searches 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 your vimrc to also make :find {name} (without globs) search recursively — then just :find models<Tab> works
  • Pair with set wildmenu for a visual completion menu above the command line
  • :sfind **/*.py opens the file in a horizontal split; :vert sfind for a vertical split
  • Combine with set wildignore+=*/node_modules/*,*.pyc to exclude unwanted files from completion

Next

How do I define custom fold marker strings instead of the default {{{ }}} in Vim?