1

I'm working in a react project and opened vim from the root folder. When I'm using

:vimgrep /pattern/ **

I just can search everywhere, but I want to search everywhere except the 'node_modules' folder.

How can I create a mapping to exclude specific folder names permanently from searching?

1

Try the following:

set wildignore=*/node_modules/*

I just played a little with wildignore, so I don't know if it works in all cases.

E.g. if you do a

:vimgrep /pattern/ node_modules/**

It will find nothing, as all files below node_modules are ignored.

See :help wildignore.


Update:

The option wildignore is a comma-separated list of pattern. To ignore multiple directories use:

set wildignore=*/node_modules/*,*/target/*,*/tmp/*
  • Is there a way that I can exclude multiple folders? – ChrKahl Feb 14 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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