A number of answers work well for older versions of IntelliJ, but in 2020.2, and possibly other recent versions, I keep seeing excluded folders in my search results. In my case: node_modules
.
I found something that does work, though. For javascript projects, at least. There might be something similar available for other languages.
- First, of course, exclude the directory from your project.
Hopefully this works, but if it doesn't, and you're using Javascript, continue:
- Go to Settings -> Languages & Frameworks -> Javascript -> Libraries
- There, uncheck all the directories you don't want included in your search.
Whether this is a good idea remains to be seen; IntelliJ doesn't merely exclude them from your search, but from all its code parsing, which means it might not recognise imports from that directory either. For me it seems to work fine at the moment, but I give no guarantees. Try it, but remember how to revert this.
It's an ugly work around. IntelliJ clearly needs a better way to exclude directories from searches.