10

I want to exclude a file from the PhpStorm global search (Ctrl+Shift+F) but not exclude the file from the project itself. A good use case would be to avoid searching inside files like jQuery.js, but in my particular case, I have a plugin that generates code and it clutters my search results.

Being specific, this is the example search result: search-results

The first result is uselss and will always be for me. So I would like to exclude it from the results. However, if I exclude it from the project then it will not be included in the auto-complete features of PhpStorm, which is the sole purpose of that file in the first place.

Or are there any alternatives to this? I could select a folder and search only there, but it is not as convenient as just pressing Ctrl+Shift+F directly from the editor

santiago arizti
  • 4,175
  • 3
  • 37
  • 50

4 Answers4

19

You can do that defining a scope

First of all you have to define a scope containing all the directories of your project that you want to be "searchable".

Go to Appereance & Behaviour -> Scopes and create the scope

Then, in the "Find in Path" window you can select the Custom scope you want to use for the search

Moppo
  • 18,797
  • 5
  • 65
  • 64
  • 1
    Oh this is nice! at first I thought I had tried this solution before, but I followed it step by step and it is exactly what I was looking for. Thank you :--) – santiago arizti Jan 18 '16 at 21:49
17

Right-click on the folder > Mark directory as > Excluded

enter image description here

Alexander Mikhalchenko
  • 4,525
  • 3
  • 32
  • 56
  • 9
    Unfortunately the file is inside root folder of my project so I would have to exclude the whole project for this :p – santiago arizti Jan 18 '16 at 21:51
  • Works for directories but not files. Files can be excluded from code completion by marking them as plain text but they are still included in global search. – daniels Jul 07 '21 at 09:56
3

When You press Ctrl+Shift+F there is an option for scope where you can specify the files you want to search.

PhpStorm

Community
  • 1
  • 1
Stanley Nguma
  • 176
  • 1
  • 4
  • non of the predefined options in the "custom:" select box helped me, it seems the file I want to exclude is part of the project and I cannot exclude it. Maybe if the VCS filters in that box included the option to search inside all version controlled files (and not just the changed ones) I could .gitignore the unwanted file and that would be enough. But no option exists. – santiago arizti Jan 18 '16 at 21:44
  • I am also trying the "file masks" box but I have not found how to negate a mask. This way I could put the mask "oxid.meta.php" and search in files not matching the mask, but no luck yet. – santiago arizti Jan 18 '16 at 21:45
  • You can negate masks with a preceding `!` exclamation mark. I.e. `!*.min.css,!*.min.js` – WoodrowShigeru Mar 07 '23 at 08:04
1

You can go to settings/preferences -> Editor -> File Types and then add a rule to the Ignored Files and Folders.

PhpStorm File Types settings

rowBawTick
  • 11
  • 1