8

So in Visual Studios you can "Find in files" a string - I find this very useful to locate a file in which some markup or JS may be found, I use VS for my main code editor for Web development.

The problem is, most of my projects use node.js and node based build tools grunt/gulp etc. so I have a node_modules folder somewhere in my project that makes the FIND take for ever as there are thousands of files!!

How can I search in files and folders for a string BUT not in a node_modules directory.

In SublimeText2 you can remove a folder from the project without deleting it, this will stop a search looking in there...

A RegExp will be for the string not the filePath :(

Will Hancock
  • 1,240
  • 4
  • 18
  • 27
  • 1
    Can you exclude the node_modules folder from the project? Alternatively can you hide the node_modules folder (do they have a common root), by setting the Hidden attribute on the folder? – alergy Jun 17 '14 at 14:30
  • 1
    That's a good idea, it stops Visual Studio searching inside & doesn't stop Grunt from running. - would need to test this idea running a node server and gulp. I don't mind making the folder hidden on each project a fairly small change to stop irritation and increase #velocity – Will Hancock Jun 17 '14 at 15:34

2 Answers2

13

Ok so I've tried this and it seems to work.

You can hide the node_modules folder (if they have a common root), by setting the Hidden attribute on the folder. As you say it fulfils your needs as per the question.

alergy
  • 974
  • 1
  • 14
  • 28
  • 4
    Thanks @alergy, adding the hidden attribute on the node_module directory worked for me. However, I also had to refresh the solution explorer for the search to actually exclude the hidden directory. – cookch10msu May 19 '15 at 13:28
2

2020 Version

Add the following exclusion

!*\node_modules\*;!*\bin\*;!*\obj\*;!*\.*

enter image description here