Exclude folder from search but not from the project list

PhpPhpstormWebstorm

Php Problem Overview


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

Php Solutions


Solution 1 - Php

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.

Solution 2 - Php

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

Solution 3 - Php

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).

Solution 4 - Php

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionVitalii PetrychukView Question on Stackoverflow
Solution 1 - PhpJustinasView Answer on Stackoverflow
Solution 2 - PhpTheRealJAGView Answer on Stackoverflow
Solution 3 - PhpAndrewView Answer on Stackoverflow
Solution 4 - PhpRoestVrijStaalView Answer on Stackoverflow