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?

Answer

set path+=**

Explanation

By adding ** to Vim's path option, you enable recursive directory search — which makes :find with tab completion a lightweight project-wide fuzzy finder, no plugins required. Typing :find mod<Tab> will search all subdirectories and present matching files for completion.

How it works

  • path controls where Vim looks when searching for files with :find, gf, and similar commands
  • The ** glob means "search recursively through all subdirectories"
  • :find with tab completion lists all matching files found in path
  • After adding **, :find searches the current directory tree exhaustively

Add this to your ~/.vimrc or init.vim:

set path+=**

Then optionally suppress the directory listing (it gets noisy in large projects):

set wildignore+=*/node_modules/*,*/.git/*,*/vendor/*

Example

With a project structure like:

project/
  src/
    models/user.go
    models/order.go
  cmd/
    main.go

From the project root, type:

:find user<Tab>

Vim completes to src/models/user.go and opens it.

Tips

  • :find *user*<Tab> matches any path containing "user" — use * as a wildcard within the filename
  • :sfind opens the file in a horizontal split, :vfind in a vertical split
  • Combine with set wildmenu and set wildmode=list:longest for a richer tab-completion experience
  • For very large codebases, limit ** to a subdirectory: set path+=src/**

Next

How do I define autocmds safely so they don't duplicate when my vimrc is re-sourced?