Skip to content

Instantly share code, notes, and snippets.

@yeasinat
Last active September 8, 2025 09:50
Show Gist options
  • Select an option

  • Save yeasinat/df6751eeb82d54b4668850fc02dbc72d to your computer and use it in GitHub Desktop.

Select an option

Save yeasinat/df6751eeb82d54b4668850fc02dbc72d to your computer and use it in GitHub Desktop.
Fuzzy Finder (fzf) in NVIM

Setting Up and Using fzf.vim in Neovim

This note summarizes the steps to install and use fzf.vim in Neovim for efficient file navigation. It's minimal, clean, and focused on key actions. Assumes Ubuntu-like system (e.g., using apt).

Prerequisites

  • Neovim installed: sudo apt install neovim
  • fzf installed: sudo apt install fzf
  • ripgrep for faster searches (optional but recommended): sudo apt install ripgrep
  • bat for file previews (optional): sudo apt install bat

Step 1: Install vim-plug (Plugin Manager)

Run in terminal:

curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs \
  https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

Step 2: Configure init.vim

Open ~/.config/nvim/init.vim:

nvim ~/.config/nvim/init.vim

Add this content:

call plug#begin('~/.config/nvim/plugged')
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
call plug#end()

" Keybindings
nnoremap <C-p> :Files<CR>     " Ctrl-p: File search
nnoremap <Leader>b :Buffers<CR> " \b: Buffer switch
nnoremap <Leader>f :Rg<CR>     " \f: Content search

" Optional: Previews and ignores
let g:fzf_preview_window = ['right:50%', 'ctrl-/']
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!{.git,node_modules}"'

Save and exit (:wq).

Step 3: Install Plugins

Open Neovim:

nvim

Run:

:PlugInstall

Close the window (:q) when done.

Step 4: Reload Configuration

In Neovim:

:source ~/.config/nvim/init.vim

Usage Guide

Open Neovim in a project:

cd ~/myproject
nvim

Key Commands

  • File Search: Ctrl-p or :Files

    • Type partial name (e.g., mnc for main.c).
    • Enter: Open in current buffer.
    • Ctrl-t: New tab. Ctrl-x: Horizontal split. Ctrl-v: Vertical split.
    • Ctrl-/: Toggle preview (if bat installed).
  • Buffer Switch: \b or :Buffers

    • Switch between open files.
  • Content Search: \f or :Rg pattern

    • Search text across files (e.g., :Rg function main).
  • Git Files: :GFiles (in Git repos, ignores untracked).

  • Lines in Buffers: :Lines (search open files).

Tips

  • Fuzzy matching: Non-consecutive letters work.
  • Previews: Press Ctrl-/ in search windows.
  • Troubleshooting: :PlugStatus to check plugins. :help fzf-vim for docs.

This setup makes navigating files fast and intuitive. Update init.vim and :source as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment