intellij-idea

How can I tell IntelliJ's "Find in Files" to ignore generated files?


I need to do a find in files. I want to ignore or exclude generated files, like JAX-WS artifacts or classes in target folders. How can I tell IDEA to exclude these files from the find?


Solution

  • Create a Custom Scope defining the set of files to include/exclude from your search.

    1. CTRL+SHIFT+F for the Find in Files dialog. (Mac users press command+shift+F)

    2. Click on Scope

      Click on Scope

    3. Choose a scope from the drop down list or create a Custom Scope by clicking on the ... button to the right of drop-down.

    4. In the dialog that appears, click on the + button on the top left hand and select Local and give your Custom Scope a name (you can change it later)

    5. The buttons on the right allow you to Include and Exclude individual files and Recursively Include or exclude all files beneath a folder.

      adding a custom scope for handwritten files

    The Filter Button icon, bottle filter is useful; clicking on it toggles the file display to show what files are present in the Scope as you create it. Toggle the Filter on and off to ensure that your Custom Scope is as expected.

    The Pattern field can be manually tweaked if you needed to refine the files contained in the custom scope further (say if you wanted to target files that were not yet present on disk)

    Once created, subsequent Find in Files can make use of your Custom Scope to restrict which files are searched as per your stated needs.

    For more details of the 2024 features around Custom Scopes visit

    https://www.jetbrains.com/help/idea/2024.1/settings-scopes.html

    and for documentation on the pattern syntax used by Scopes see

    https://www.jetbrains.com/help/idea/2024.1/scope-language-syntax-reference.html (thanks Didier L for this ref and the feedback that triggered the 2024 update)