How do I find a file by name in Vim's path and open it in a new tab?
Answer
:tabfind {name}
Explanation
:tabfind is the tab-aware counterpart to :find. It searches all directories in Vim's path setting for a file matching {name} and opens the result in a new tab page rather than the current window. This gives you a clean way to navigate to project files without disturbing your current split layout.
How it works
- Vim searches each directory listed in
'path'in order until it finds a match - Wildcards are supported:
:tabfind main*finds the first file starting withmain - Tab completion works on the filename argument (after setting up
pathcorrectly) - Typically paired with
set path+=**in yourvimrcto enable recursive project-wide search
Example
With set path+=** in your config and a project like:
project/
src/
auth.go
main.go
tests/
auth_test.go
From anywhere in the project:
:tabfind auth.go
Opens src/auth.go in a brand new tab page.
Tips
:findopens in the current window;:sfindopens in a horizontal split;:tabfindopens in a new tab- Use
<Tab>completion with:tabfindto browse matches without knowing the exact path - Combine with
set wildmenuandset wildmode=list:longestfor an interactive completion menu - For fuzzy matching by partial name use
:tabfind *auth*