Is there a way to exclude certain folders (and all their subfolders) from searching within Eclipse?
-
1Googlers: see (atzz's answer:) https://stackoverflow.com/a/6111002/1599699 - this is the answer you're looking for, not the accepted answer. – Andrew Jun 14 '17 at 17:11
-
@Andrew this is now the accepted answer – Dónal Mar 12 '20 at 09:37
-
JUSTICE FOR ALL OF MANKIND! – Andrew Mar 13 '20 at 06:13
6 Answers
The quick and dirty way:
Right click on a folder, go to properties, and mark a folder as derived. Derived entities are excluded from searching by default. The problem with this approach is that Eclipse "forgets" that the folder is derived if you delete it (either from within Eclipse or externally, followed by refreshing the project tree). Like so often with Eclipse, this is a long-standing bug (10 years in this case) which still applies to the current version (4.6 Neon at the time of writing).
The safe way:
Create a working set including only those entities you want searched and search only within that working set. See Dave Ray's answer for details on this procedure.

- 1
- 1

- 14,825
- 5
- 34
- 41
-
2Like Dave noted in his answer: setting things that are not really derived to be derived might cause problems. Like when using Maven to create a distribution. – Arjan Jan 12 '10 at 08:40
-
2In Juno, marking a folder as derived does not exclude it from search. I'm working on Mac OS so it may be related to that as I'm seeing a number of features not working correctly on this OS – Marc Jan 25 '13 at 13:16
-
Works for me on Juno SR2 under MS-Windows XP. And the folder that annoyed me was actually derived (the build folder, with listing files sometimes resulting in zillions of hits). – starblue Apr 09 '13 at 08:20
-
@Instantsoup Why can't the search itself exclude the folders? I mean, it has the "!" character just for this, no? I don't understand why it doesn't work for me. – android developer Apr 18 '13 at 18:25
-
3Creating 'a working set including only those entities you want searched' is not a very safe way of doing it. In fact an INCLUSIVE filter is quite unsafe. Imagine creating a new directory or file that is a sibling to one that is excluded. In that instance you will have to remember to INCLUDE it in the search. If you forget, search has false negatives which can be dangerous and lead you to believe that Eclipse search is unreliable. – JW. Nov 22 '14 at 05:34
-
Just in case anyone will be wondering at some point, this works on Eclipse's version 4.5.1 for PHP as well. I am posting, because someone asked me, so I guess someone else could be wondering the same. – Dimitris Damilos Nov 16 '15 at 16:00
-
@androiddeveloper: Concerning your first comment - You're referring to the "File name patterns" section of the search dialog, which is for **file names** not directory/path names. – zb226 Sep 21 '16 at 12:13
-
It would be nice that eclipse could assume anything matching the `.gitignore` files to be derived. As a matter of fact, in 4.19, it adds it to a local `.gitignore` whenever you mark a folder as 'derived'. – YoYo Jan 13 '22 at 19:12
Here is what works for me (I'm using Helios - maybe this way was not available when this question was originally asked?)
- Go to Project -> Properties -> Resource Filters.
- Click Add.
- Choose Filter type: Exclude all
- Choose Applies to: Folders; check All children (recursive).
- In the Attributes, choose Name, Matches,
.svn
(for example).
(Actually, I'm using .*
to filter out .svn, .hg etc. in one go.)
After okay'ing the project properties dialog, these directories won't come up in search any more. In fact, Eclipse is so kind as to automatically update existing search results windows and remove all matches which are now filtered out.

- 17,507
- 3
- 35
- 35
-
27For latest versions of Eclipse as of 2011 (Helios & Indigo), this should be the accepted answer and the easiest way to do it. – András Szepesházi Nov 07 '11 at 22:22
-
9As this can only be applied to one project at a time, it's really not a gain over marking folders derived... and depending on how many times you need to type in the filters, it could take longer. – egid Jan 10 '12 at 22:17
-
When using this method, be sure to also clear your search history (using the flashlight-with-a-down-arrow button in the search panel) after adding the resource filter. Otherwise you won't save any search time, and you'll get `.git/.../filename.file doesn't exist` errors because the search cache (I think?) still considers the .git folder to be a valid place to look. – coredumperror May 10 '12 at 00:33
-
20This works but hides the files in the package explorer. We may want to edit the files but not see them in search results. – Aram Kocharyan Oct 30 '12 at 10:13
-
When I tried, this it worked for filtering search results, but I started getting errors "Errors running builder 'AspectJ Builder' on project 'Mercadosa-webapp'. Resource already exists on disk: '/MyProject/target/MyProject-1.0/WEB-INF/freemarker/site/file.ftl'. Resource already exists on disk: '/MyProject/target/MyProject-1.0/WEB-INF/freemarker/site/file.ftl'." – Marc Jan 25 '13 at 13:23
-
Just like @AramKocharyan said. for that reason, I prefer the answer from Dave Ray. – ajon Sep 08 '15 at 19:34
-
In Mars, probably earlier versions as well, access through: Project -> Properties -> Resource -> Resource Filters – jomofrodo Jun 20 '16 at 20:57
-
This. is. awesome. I gave it a shot, and it live=filtered my existing searches. Thanks! – Blake Neal Oct 27 '17 at 13:43
-
Maybe don't do this. After I add ".*" my ESP32 CDT build broke. Then I removed the filter and did Project->Clean and it worked again. Just a coincidence? – user103185 Apr 25 '18 at 12:28
I could imagine that marking resources derived might cause problems in other areas. Instead, create a working set with the folders you want to include in the search:
- Open Search dialog (Ctrl + H)
- Change search scope to Working Set
- Click Choose ...
- Click New to create a new Working Set with the what you want searched (or Add All and then remove the ones you want filtered

- 8,719
- 5
- 40
- 68

- 39,616
- 7
- 83
- 82
-
5This has issues too. See my comment under Instantsoup's answer above. With this INCLUSIVE filter, in some cases, when you add files or folders you have to remember to include them in search. If you forget you get dangerous false negatives. Which is not ideal. – JW. Nov 22 '14 at 05:47
-
In Eclipse Kepler there is a "Select a working set type" dialog that comes up after clicking New. (Worth noting that to find all types of file need to select "Resource" at this point.) – Steve Chambers Oct 08 '15 at 11:17
- Right click on your project
- Select
Properties
- Select
Resource
->Resource filters
- Click
Add filter
- Choose the following settings:
- Exclude all
- Files and folders
- All children (recursive)
- Change
Name
forProject Relative Path
- Fill input text with
(bin$|bin/.*|build/.*|build$)
(replacebin
andbuild
by the names of the folders you want to exclude) - Tick
Regular expression
Hit OK and then Apply.
Disclaimer
This builds on @atzz's answer, which helped me figure this out. However while it did answer the question of how to exclude certain files, it didn't answer the question of how to exclude certain folders.

- 9,888
- 6
- 55
- 76
The best quick and dirty way in Eclipse Juno:
- Right click on the folder.
- Go to Properties.
- Go to C/C++ Build.
- Check "Exclude resource from build".
- Click in OK button.
- Right click on the project.
- Go to Index.
- Click Rebuild.
- Relax!

- 36
- 2
Excluding a folder or file from being searched in Eclipse
1 Right-click on the file/folder.
3 Click on the "Properties" option.
4 Select the "Resource" option.
5 Place a check next to the "Derived" attribute.
Hope is help.

- 1,765
- 13
- 12