How to Ignore Generated Files in IntelliJ's Find in Files (Search Bar)
I recently needed a way to ignore, or exclude, generated and build files from IntelliJ’s
Find in Files function.
In particular, I only wanted to search relevant source and configuration files (e.g.
To ignore generated files, we need to create a Custom Scope.
Find in Files
First, let’s open
Find in Files.
- On Windows:
- On Mac:
We can also go to
Find in Files... to open the dialog.
2. Open up Scope Tab
Find in Files dialog, navigate to the
Select the ellipsis (three dots) icon:
This should open up another modal window.
3. Create a custom scope
Click on the plus icon (
+) and create a
We can name our scope
Exclude generated files.
We want to ignore searching all files in our
target directory, which contains the compiled version of our source.
Pattern input box, let’s place the following:
This means that our
Find in Files search will only search files not in the
3.1. Add more conditions to narrow scope
Suppose we also want to avoid searching
We can append to our pattern using boolean operators.
Let’s also ignore
Once we’re done editing our scope, remember to click
4. Use scope in
Find in Files
Now, in the
Scope tab of
Find in Files, click the dropdown and select the scope we created earlier.
My scope says
Exclude generated files, and all searches under this scope will ignore compiled, build files.