How to exclude a file extension from IntelliJ IDEA search?(根据条件过滤搜索结果,比如:file:*.xml)

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.

2 Answers

up vote80down voteaccepted

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

How to exclude a file extension from IntelliJ IDEA search?(根据条件过滤搜索结果,比如:file:*.xml)

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.

How to exclude a file extension from IntelliJ IDEA search?(根据条件过滤搜索结果,比如:file:*.xml)

Examples of Patterns for Pattern field:

  • file[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!