How to get fzf.vim ignore node_modules and .git folders?

doctopus picture doctopus · May 18, 2020 · Viewed 11.2k times · Source

I have fzf setup in vim with barely any customisation:

" fzf and ripgrep settings
set rtp+=/usr/local/opt/fzf
let g:fzf_action = {
    \ 'ctrl-t': 'tab split',
    \ 'ctrl-i': 'split',
    \ 'ctrl-s': 'vsplit'
    \ }

In my .bash_profile, I set the environment variable FZF_DEFAULT_COMMAND to show hidden, but ignore node_modules and .git:

export FZF_DEFAULT_COMMAND='rg --files --follow --no-ignore-vcs --hidden -g "!{node_modules/*,.git/*}"'

However, when I use :Files function in vim, it still searches in the folders i want ignored.

Answer

undg picture undg · Jun 18, 2020

Have you tried :GFiles command?

It is one of the best FZF command that is excluding anything that is in .gitignore.

Personally I like to use it as default.

:help fzf-vim-commands