How do I fuzzy-search and switch between open buffers in Vim?
Answer
:Buffers
Explanation
The fzf.vim plugin provides the :Buffers command, which opens a fuzzy-searchable list of all your open buffers. Instead of memorizing buffer numbers or cycling through them one by one with :bnext, you type a few characters to instantly narrow down and jump to the buffer you need.
How it works
With fzf.vim installed and configured, run:
:Buffers
A floating window (or split, depending on your configuration) appears listing every open buffer. Start typing any part of the filename, path, or buffer number to fuzzy-filter the list. Press <CR> to open the selected buffer in the current window.
Key bindings inside the fzf window
<CR> " open selected buffer in the current window
<C-t> " open selected buffer in a new tab
<C-x> " open selected buffer in a horizontal split
<C-v> " open selected buffer in a vertical split
<C-j> " move selection down
<C-k> " move selection up
<Esc> " cancel and close the fzf window
Recommended mapping
Add a fast key binding to your vimrc so you can summon the buffer list instantly:
nnoremap <leader>b :Buffers<CR>
Now pressing <leader>b at any time brings up the fuzzy buffer switcher.
Why this beats built-in buffer commands
| Built-in approach | Downside |
|---|---|
:ls + :b N |
Requires reading the list, finding the number, then typing it |
:bnext / :bprev |
Linear cycling — slow when you have many buffers |
:b partial<Tab> |
Tab completion only matches from the start of the name |
With :Buffers, you type any substring — a directory name, a file extension, or even part of the path — and the fuzzy matcher finds it immediately.
Preview support
Enable buffer previews by adding to your vimrc:
let g:fzf_vim = {}
let g:fzf_vim.preview_window = ['right,50%', 'ctrl-/']
Now the :Buffers window shows a live preview of each buffer's content as you move through the list, making it easy to find the right file even when names are similar.
Tips
- Combine
:Bufferswith:Filesand:Rgto cover the three main navigation patterns: switching buffers, opening new files, and searching file contents - Use
:Historyfrom fzf.vim to fuzzy-search recently opened files, including closed buffers - fzf.vim requires the
fzfbinary — install it withbrew install fzfon macOS or your system's package manager - For Neovim users, telescope.nvim offers a similar experience with its
:Telescope bufferscommand