15

I'm using the :find command as my "fuzzy file searcher" in Vim. My setup:

set path=,,**
nnoremap <leader>f :find *

However, I'm having trouble ignoring folders. Huge folders that contain dependencies, like node_modules, slow down the search a lot and of course pollute the results with things I don't want.

I've tried the following, with no luck:

set wildignore+=node_modules/*
set wildignore+=node_modules/**
set wildignore+=node_modules/**/*

What do I need to do? Thanks

1
  • How is it possible there isn't a solution for this??
    – math2001
    Aug 22, 2017 at 6:08

1 Answer 1

18

The following enables fuzzy file search (i.e :find script.js) through every file in your project root while excluding the node_modules dir and its contents.

set path+=**                                                                    
set wildignore+=**/node_modules/** 

Tested on:

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 11 2017 13:57:34) MacOS X (unix) version (Compiled by Homebrew)

2
  • set is missing in the second line.
    – elquimista
    Jun 1, 2018 at 13:17
  • it seems like this filters out matches in the node_modules directory during tab-completion, but doesn't prevent :find from searching in there, resulting in a slower :find
    – rampion
    Nov 29, 2021 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.