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

How do I open a file by name by searching through my project directories?

Answer

:find {filename}

Explanation

:find searches for a file in all directories listed in the path option and opens it in the current window. Unlike :edit, you do not need to type the full path — Vim searches the configured directories for you. It also supports tab completion and glob patterns, making it a lightweight built-in alternative to plugin-based fuzzy finders.

How it works

  • :find filename — searches path directories for an exact filename match
  • :find *.vim — uses a glob to find the first matching file
  • Tab-complete after :find to see all reachable files in path
  • :sfind opens the result in a horizontal split; :vert sfind in a vertical split

The path option defaults to the current directory and a few standard locations. To search an entire project tree recursively, add ** to path:

:set path+=**

This allows :find utils.py to locate src/utils/utils.py without typing the full path.

Example

" With path=.,/usr/include,**
:find config.lua
" → opens the first config.lua found anywhere under the working directory

:sfind models/*.rb
" → opens the first matching .rb file in a horizontal split

Tips

  • Use <Tab> after :find to see and cycle through all matching files
  • :set path? shows the current path value
  • :find respects wildignore, so add *.pyc, node_modules/** etc. to that option to declutter results
  • :help :find for full documentation

Next

How do I enable matchit so % jumps between if/else/end style pairs?