从 Eclipse 搜索中排除文件夹
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/443169/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Exclude folders from Eclipse search
提问by Dónal
Is there a way to exclude certain folders (and all their subfolders) from searching within Eclipse?
有没有办法从 Eclipse 中的搜索中排除某些文件夹(及其所有子文件夹)?
采纳答案by atzz
Here is what works for me (I'm using Helios - maybe this way was not available when this question was originally asked?)
这是对我有用的方法(我正在使用 Helios - 也许最初问这个问题时这种方式不可用?)
- 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).
- 转到项目 -> 属性 -> 资源过滤器。
- 单击添加。
- 选择过滤器类型:排除所有
- 选择适用于:文件夹;检查所有孩子(递归)。
- 在 Attributes 中,选择Name,Matches,
.svn
(例如)。
(Actually, I'm using .*
to filter out .svn, .hg etc. in one go.)
(实际上,我正在使用.*
一次性过滤掉 .svn、.hg 等。)
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 existingsearch results windows and remove all matches which are now filtered out.
确定项目属性对话框后,这些目录将不再出现在搜索中。事实上,Eclipse 非常友好,可以自动更新现有的搜索结果窗口并删除所有现在被过滤掉的匹配项。
回答by Instantsoup
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).
右键单击文件夹,转到属性,然后将文件夹标记为派生文件夹。默认情况下从搜索中排除派生实体。这种方法的问题在于,如果您删除文件夹(从 Eclipse 内部或外部,然后刷新项目树),Eclipse 会“忘记”该文件夹是派生的。与 Eclipse 一样,这是一个长期存在的错误(在这种情况下为 10 年),它仍然适用于当前版本(撰写本文时为 4.6 Neon)。
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 answerfor details on this procedure.
创建一个工作集,仅包含您要搜索的那些实体,并仅在该工作集内进行搜索。有关此过程的详细信息,请参阅Dave Ray 的回答。
回答by Dave Ray
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
- 打开搜索对话框 ( Ctrl+ H)
- 将搜索范围更改为工作集
- 点击选择...
- 单击新建以使用您要搜索的内容创建新的工作集(或全部添加,然后删除要过滤的内容)
回答by DiFS
The best quick and dirty way in Eclipse Juno:
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!
- 右键单击文件夹。
- 转到属性。
- 转到 C/C++ 构建。
- 选中“从构建中排除资源”。
- 单击确定按钮。
- 右键单击该项目。
- 转到索引。
- 单击重建。
- 放松!
回答by Vic Seedoubleyew
- 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
- 右键单击您的项目
- 选择
Properties
- 选择
Resource
->Resource filters
- 点击
Add filter
- 选择以下设置:
- 排除所有
- 文件和文件夹
- 所有孩子(递归)
- 更改
Name
为Project Relative Path
- 填写输入文本
(bin$|bin/.*|build/.*|build$)
(替换bin
并按build
您要排除的文件夹的名称) - 打钩
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.
这是建立在@atzz 的回答之上的,它帮助我解决了这个问题。然而,虽然它确实回答了如何排除某些文件的问题,但它没有回答如何排除某些文件夹的问题。
回答by superup
Excluding a folder or file from being searched in Eclipse
排除在 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.
希望是帮助。