php 从搜索中排除文件夹,但不从项目列表中排除
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16559203/
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 folder from search but not from the project list
提问by Vitalii Petrychuk
I have a few different project with the same core
.
我有几个不同的项目,使用相同的core
.
All I need is to mark all not current projects as excluded
to avoid searching through them (simple search, shift + cmd + n etc.)
我所需要的只是标记所有非当前项目excluded
以避免搜索它们(简单搜索、shift + cmd + n 等)
In other words I want to have a search results from the core
+ current project
.
换句话说,我想从core
+ 中获得搜索结果current project
。
Is there are any way do close
some projects but have them available in the projects list
and open
it so easy as it was closed? Or probably you have another experience?
有什么办法可以做close
一些项目,但让它们可用,projects list
而且open
它很容易关闭?或者你可能有其他经历?
采纳答案by Justinas
To apply custom search use Scopes Setting
> Project Settings
> Scopes
to use it for Find in Path
or Replace in Path
.
I suggest to reorganize your folders, so that no unnecessary files are left in project directory. Also, you can specify Source Root by going to Settings
> Project Settings
> Directories
and adding additional directories.
要应用自定义搜索使用范围Setting
> Project Settings
>Scopes
使用它Find in Path
或Replace in Path
。
我建议重新组织你的文件夹,这样就不会在项目目录中留下不必要的文件。此外,您可以通过转到Settings
> Project Settings
>Directories
并添加其他目录来指定 Source Root 。
回答by Andrew
As of version 2016.3this is found under Settings> Appearance & Behavior> Scopes.
从2016.3版本开始,这可以在 Settings> Appearance & Behavior> Scopes 下找到。
Or regardless of the version, just go to Settingsand type "scopes" into the search box at the top.
或者无论版本如何,只需转到“设置”并在顶部的搜索框中键入“范围”。
Then just click the + symbol to add the scope, choose the folder you want to exclude, and click Exclude Recursivelyand apply.
然后只需单击 + 符号添加范围,选择要排除的文件夹,然后单击Exclude Recursively并应用。
Then when you search using CTRL+SHIFT+F, under Options > Scope select Custom and choose the scope you just created (thanks commenters).
然后,当您使用 CTRL+SHIFT+F 进行搜索时,在选项 > 范围下选择自定义并选择您刚刚创建的范围(感谢评论者)。
回答by TheRealJAG
This is the best way to exclude directories from your search results. I work on large Magento project with many directories I don't want in search results. This solved my problem. If your project contains a /vendor directory, this will help speed up indexing in PHPStorm since it's ignored.
这是从搜索结果中排除目录的最佳方法。我在大型 Magento 项目上工作,其中有许多我不希望出现在搜索结果中的目录。这解决了我的问题。如果您的项目包含 /vendor 目录,这将有助于加快 PHPStorm 中的索引编制,因为它被忽略了。
Right click on any folder to bring up the following options.
右键单击任何文件夹以显示以下选项。
回答by RoestVrijStaal
Like @Justinas and commenters said: You could make a custom scope and annoy yourself every time by selecting that custom scope when using Find in Path(and similar) because PhpStorm does not use that custom scope by default ?♂?
就像@Justinas 和评论者所说的那样:您可以在使用Find in Path(和类似功能)时选择该自定义范围来创建自定义范围并每次惹恼自己,因为 PhpStorm 默认不使用该自定义范围?♂?
Excluding the node_modulesdirectory breaks autocompletion and other code assistance functionality anyway. You don't want to do that.
无论如何,排除node_modules目录会破坏自动完成和其他代码辅助功能。你不想那样做。
However, I found a hackwhich does not require any directory exclusionof node_modulesnor a custom scope:
但是,我发现了一个hack,它不需要node_modules 的任何目录排除,也不需要自定义范围:
- Close PhpStorm. Ensure it's not running.
- Open name_of_your_project.imlin the .ideadirectory within your project directory with your favourite text editor. As long as it isn't PhpStorm.
- Remove the line
<content url="file://$MODULE_DIR$/node_modules" />
- Save.
- Enjoy life again.
- 关闭 PhpStorm。确保它没有运行。
- 使用您喜欢的文本编辑器打开项目目录中.idea目录中的name_of_your_project.iml。只要不是 PhpStorm。
- 删除该行
<content url="file://$MODULE_DIR$/node_modules" />
- 节省。
- 再次享受生活。
I find it amateurish of JetBrains to include dependency storage directorieslike node_modulesof JavaScript/TypeScript and vendorof PHP by default. There is barely any use case to include those directories in find & replace functionality, left alone refactor functionality.
我发现 JetBrains 的业余爱好是默认包含依赖项存储目录,例如JavaScript/TypeScript 的node_modules和PHP 的供应商。几乎没有任何用例将这些目录包含在查找和替换功能中,更不用说重构功能了。