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— searchespathdirectories for an exact filename match:find *.vim— uses a glob to find the first matching file- Tab-complete after
:findto see all reachable files in path :sfindopens the result in a horizontal split;:vert sfindin 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:findto see and cycle through all matching files :set path?shows the current path value:findrespectswildignore, so add*.pyc,node_modules/**etc. to that option to declutter results:help :findfor full documentation