Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 250
Freiheit Avatar asked May 21 '13 13:05

Freiheit


2 Answers

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

  1. CTRL+SHIFT+F for the Find in Path dialog. (Mac users press command+shift+F)
  2. Under Scope select Custom.

    Find in Path

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

  4. In the dialog that appears, click on the + button and select Local
  5. On the right pane you can Include and Exclude individual files and Recursively include or exclude all files beneath a folder.

Now when you use Find in Path, use your custom scope to restrict which files are searched.

I suspect from the reference to Find in Files in your question that these instructions may not apply to your version but it is useful to know that this functionality exists and there is always the 30 day evaluation version.

like image 69
Rob Kielty Avatar answered Sep 28 '22 22:09

Rob Kielty


I know this is late to the party, and Rob's answer is a decent one. I'd just like to add the following alternative though: if you chose the Custom scope (as in Rob's answer), then leave the selection at Project Files, this will make IntelliJ search a bit more selectively than by default. I don't know what the exact differences are, but of particular interest is that if you mark a directory as Excluded either using the Modules tab in the Project Structure settings, or by right-clicking on a directory and selecting Mark Directory As -> Excluded.

If the files you want to exclude are in a single or relatively few directories so you can easily manually set up these exclusion rules, this is a really nice way of getting the same result without needing to configure a custom scope.

I tested this in IntelliJ Ultimate 14.1.4. I have no idea how it behaves in other versions, but I suspect most of v14 at least will behave the same.

like image 30
Thor84no Avatar answered Sep 28 '22 23:09

Thor84no