Is there a way to exclude particular file extension from the results in IntelliJ IDEA's "Find in Path" dialog (invoked by CTRL + SHIFT + F)? I want to exclude all .css
files.

- 6,138
- 12
- 49
- 61

- 6,471
- 9
- 50
- 71
7 Answers
In intellij 16 there is a section "File name Filter" to exclude an extension use !*.java
. You can give more detailed patterns as well for example I use the pattern below to only return .java files except those with a name starting or ending with test.
Pattern: !*test.java,*.java,!Test*.java
In recent versions of Intellij the GUI has been updated a bit but the same still applies see the "File mask" on the top right hand corner see image below:

- 7,585
- 8
- 43
- 67
-
2Can I not mention !mocks/*.json in the File Masks filter ? – CodeTweetie Oct 23 '17 at 10:12
-
1@CodeTweetie what are your doing to do with the '/' not sure why its needed (i thought '/' is just a delimiter in regex). without it your filter would say exclude any file that starts with "mock"s followed by anything ending in ".json" – Marquis Blount Oct 27 '17 at 17:13
-
1This "File name Filter" dialogue doesn't seem to exist in recent versions (2018.1, etc.). – Woodchuck Aug 06 '18 at 20:39
-
Note that this feature was added in IntelliJ 2016.1. If you're using a perpetual fallback license of IntelliJ 15 or older, this feature won't be available. [See my other post](https://stackoverflow.com/questions/36262526/intellij-file-mask-not-working-on-simple-excluding-file-pattern-why/55130341#55130341) – Kevin Mar 12 '19 at 20:49
-
For anybody who's interested, this works in Rider as well. – Ken Bonny Jan 18 '21 at 09:26
-
For php 2018, this option is in Settings > Editor > File Types > Ignore files and folders (at the bottom). It also uses standard positive/inclusion patterns (use \*.sql to exclude sql files instead of !\*.sql etc). – Jarrod Juleff Mar 26 '21 at 18:12
In "Find in Path" and "Find in Files" (Ctrl+Shift+F) you can use the "File mask" input.
For example, this would exclude all js, css and twig:
!*.js, !*.css, !*.twig
It's handy cause it also keeps a list of previous inputs, but it gets messy easily when you add a lot of extensions. If it gets too crowded, consider excluding some folders as well (right-click -> "Mark directory as" -> "Excluded")

- 11,422
- 7
- 53
- 57
-
2Frustrating that this is not documented anywhere in the docs but this is exactly what I wanted – Mike Harrison Mar 24 '22 at 15:28
-
it does not work for me, it only takes the 1st filter, am using intellij 2022.2.4 ultimate edition – Eduardo Aug 01 '23 at 16:30
You can create custom scope there: In 'Find in Path' dialog you can check radio button 'Custom' and open scopes window. There you can customize path and search pattern.
Examples of Patterns for Pattern
field:
!file:*.css
- exclude CSS filesfile[MyMod]:src/main/java/com/example/my_package//*
- include files from the directory in a project.src[MyMod]:com.example.my_package..*
- recursively include all files in a package.file:*.js||file:*.coffee
- include all JavaScript and CoffeeScript files.file:*js&&!file:*.min.*
- include all JavaScript files except those that were generated through minification, which is indicated by the min extension.
Or check the official documentation.
Good luck!

- 340
- 3
- 12

- 9,176
- 6
- 57
- 100
-
2
-
3Sorry, it's in IntelliJ's documentation: http://www.jetbrains.com/idea/webhelp/scope-language-syntax-reference.html. For excluding CSS it's: !file:*.css. – Robert Kusznier Mar 03 '14 at 11:20
-
If you are like me that don't want to use the File Mask option or create a custom scope, etc. but just wanted to be able to add it to project settings one time and be done with it, then here's a solution for you.
I wanted my Find in Path to not search in lock
files (auto-generated manifest file by package managers), here's what I had to do for that:
Goto File >> Project Structure (or just press Command+;)
Select Modules under Project Settings
Add a pattern or file names to the Exclude files text-box, in this case: *.lock;package-lock.json
and hit Apply, and then ok.
Note The above option is available in IntelliJ 2019 and versions after that, not sure about older versions. For more info, https://www.jetbrains.com/help/phpstorm/excluding-files-from-project.html

- 1,027
- 8
- 9
-
The problem with this is that it also excludes files with those extensions from the build right, not just from searches!? – Suan Nov 06 '19 at 19:51
-
1@Suan as far as I know, it will only exclude the file from searches, code completion, inspections, etc. pretty much excluded from indexing. Checkout this article from JetBrains, https://www.jetbrains.com/help/phpstorm/excluding-files-from-project.html – Arun Karnati Nov 07 '19 at 20:21
-
The description is not good. It took me 5 minutes to find find this option in Project Structure. Please add another screenshot showing where exactly to find this. – Frederic Leitenberger Jun 05 '20 at 08:19
-
1
-
1Once you click on a module, you have to click "Sources" for "Exclude files" to appear. – Druska Aug 26 '20 at 15:30
-
1
-
1Many thanks, it works well, so many time lost at filtering this *.lock files. No it's over. Many love on you – MathKimRobin Feb 18 '22 at 09:58
For 2019.2, the pattern is not set in scope but in the right top windows "File mask" in Find in path
dialog. You must tick it.
The syntax I tested are:
- exclude files with extension
css
:!*.css
- exclude all under
out
dir:!out/*
Patterns are separated by comma.
Reference: https://www.jetbrains.com/help/idea/finding-and-replacing-text-in-project.html

- 11,303
- 6
- 88
- 157
For 2021.3.2, just right-click to the folder and Mark Directory as -> Excluded. This will work for logs etc but be careful about source folders.

- 51
- 4