138

I have a few different project with the same core.

All I need is to mark all not current projects as excluded to avoid searching through them (simple search, shift + cmd + n etc.)

In other words I want to have a search results from the 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?

enter image description here

4
  • 9
    Exclude from normal text search -- easy -- just define custom scope (Preferences | Scopes) and use it in "Find/Replace in path" and similar dialogs. But this will not work for "Navigate | File/Class/Symbol" as it always works with whole project. Instead of that -- better reorganize your folder structure ("having hide this folder because I do work with another one" is not correct approach).
    – LazyOne
    Commented May 15, 2013 at 17:20
  • Yeah, I one of the ways to do what I want is to create for each folder separate project and create symlink to the core folder. But I am looking for alternative ways. Commented May 15, 2013 at 17:34
  • 1
    Not necessary symlink (although I'm using that as well -- work fine for me). You can attach it as Additional Content Root instead (Preferences | Directories).
    – LazyOne
    Commented May 15, 2013 at 18:50
  • Great! Please post your response as an answer and I will accept it. Commented May 15, 2013 at 18:54

4 Answers 4

95

To apply custom search use Scopes Settings/Preferences > Appearance & Behavior > 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.

7
  • 6
    You could create Scope with this : !file[*]:.idea/*&&!file[*]:.idea//*&&!file[*]:app/cache//*&&!file[*]:app/logs//*
    – Roukmoute
    Commented Nov 12, 2014 at 10:48
  • 17
    FYI for Mac users, it's PhpStorm > Preferences > Appearance & Behavior > Scopes Commented Dec 13, 2016 at 3:30
  • I think this answer is out dated now. Setting > Project Settings > Scopes doesnt seem to exist
    – Andrew
    Commented Dec 16, 2016 at 13:47
  • 3
    @Andrew It's under Settings > Appearance & Behavior > Scopes for CE 2016.3
    – tex
    Commented Dec 19, 2016 at 21:26
  • Is there a way to do a search and not exclude the sources marked as excluded (for rare searches) Commented May 24, 2017 at 15:48
94

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.

Right click on any folder to bring up the following options.

Exclude from search

3
  • Also works for Laravel package development. Recommended way to do this to create packages folder in your project root. Now it will be using same classes as your main project so you end up getting ton of duplicate classes exists errors. Right click and do this and it works like magic. The scope approach didn't work for me! Commented Jun 2, 2020 at 23:36
  • tap-and-enjoy solution
    – CodeToLife
    Commented Sep 6, 2021 at 13:15
  • 1
    Excluding vendor will completely screw intellisense though Commented Mar 25 at 13:59
42

As of version 2016.3 this is found under Settings > Appearance & Behavior > Scopes.

Or regardless of the version, just go to Settings and 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 Recursively and apply.

Then when you search using CTRL+SHIFT+F, under Options > Scope select Custom and choose the scope you just created (thanks commenters).

3
  • 4
    Just want to add if you are using FIND like cmd+shift+F then in the options tab you can radio custom and then choose the ellipse and it opens the scope tool and you can selct or create a scope to exclude what you need. Commented Jan 14, 2017 at 0:17
  • 4
    This automatically excludes this folder's contents from the searches... after I have created my custom scope, my search Ctrl+Shift+F was still searching globally until I have explicitly selected "Custom" and picked my scope as @daveferrara1 suggested.
    – Dimitry K
    Commented Apr 3, 2017 at 11:42
  • 1
    In 2020: After clicking + the Local vs Shared choice means whether the exclusion goes into VCS or not. Then you have to Name it. Then after @DimitryK's step (now called the Scope tab) you have to choose that same name in a drop-down menu. (Is Jetbrains UX tinkering turning anyone else into a grumpy old man?)
    – Bob Stein
    Commented Jul 21, 2020 at 15:11
2

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 🤦🏻‍♂️

Excluding the node_modules directory breaks autocompletion and other code assistance functionality anyway. You don't want to do that.

However, I found a hack which does not require any directory exclusion of node_modules nor a custom scope:

  1. Close PhpStorm. Ensure it's not running.
  2. Open name_of_your_project.iml in the .idea directory within your project directory with your favourite text editor. As long as it isn't PhpStorm.
  3. Remove the line <content url="file://$MODULE_DIR$/node_modules" />
  4. Save.
  5. Enjoy life again.

I find it amateurish of JetBrains to include dependency storage directories like node_modules of JavaScript/TypeScript and vendor of PHP by default. There is barely any use case to include those directories in find & replace functionality, left alone refactor functionality.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.