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

How do I fuzzy find and open files instantly in Vim?

Answer

:Files

Explanation

The fzf.vim plugin brings the lightning-fast fzf fuzzy finder into Vim, letting you locate and open any file in your project by typing just a few characters. Instead of navigating directory trees or remembering exact file paths, :Files opens an interactive floating window where you type fragments of a filename and results narrow down in real time.

How it works

With fzf.vim installed and fzf available on your system, run:

:Files

This opens a fuzzy finder window listing every file under the current working directory. Start typing any part of the filename — characters do not need to be contiguous — and fzf filters the list instantly.

Example

To open src/components/UserProfile.tsx, you might type:

usrpro

fzf matches the fragments usr and pro against the full path, ranking UserProfile at the top. Press <CR> to open the file.

Opening in splits and tabs

From the fzf results window, use these key bindings to control how the file opens:

<CR>     " open in the current window
<C-t>    " open in a new tab
<C-x>    " open in a horizontal split
<C-v>    " open in a vertical split

Searching from a specific directory

Pass a directory argument to scope the search:

:Files src/components
:Files ~
:Files /etc

Recommended key mapping

Most users map :Files to a quick shortcut in their vimrc:

nnoremap <C-p> :Files<CR>
nnoremap <leader>f :Files<CR>

Respecting .gitignore

By default, fzf uses find to list files. Set the FZF_DEFAULT_COMMAND environment variable to use a faster, .gitignore-aware tool like ripgrep or fd:

let $FZF_DEFAULT_COMMAND = 'fd --type f --hidden --follow --exclude .git'

This dramatically speeds up file listing in large projects and automatically excludes files in your .gitignore.

Tips

  • Use :GFiles to list only Git-tracked files, which naturally respects .gitignore
  • :GFiles? shows only modified files (like a quick git status)
  • Combine with vim-rooter or set autochdir so :Files always searches from the project root
  • fzf supports multi-select: press <Tab> to mark multiple files, then <CR> to open all of them
  • The preview window can be enabled to show file contents as you navigate results

Next

How do I edit multiple lines at once using multiple cursors in Vim?