I'm searching for a string and getting matches in a source folder, and a build folder (file in source gets copied to build during build).
I do not need the build folder result.
Vim has wildignore
which helps filter out results.
Is there something similar in intelij?
Select the Privacy & security category from the left side. Scroll down and click on the Searching Windows tab. On the Searching Windows page, click on the Add an excluded folder button and select the folder that you want to hide from Windows Search. This will add the selected folder to the list of excluded folders.
Temporary ExclusionsFrom the search function, click the ellipsis to show the files to include and files to exclude text boxes. Enter any files and folder to exclude (separated by commas).
To fix the issue, be sure to close all running applications and try to delete the file. In addition, restart your PC and try to delete the file again. If that doesn't work, you might want to try moving all other files to a different folder. After doing that, try to delete the folder that has the problematic file in it.
Open the mentioned Searching Windows page in Settings. On the right, go to the section Excluded Folders. Click on the folder you want to remove. Click on the Remove excluded folder button.
Mark your build folder as excluded:
File > Project Structure > Modules > Sources > Mark as Excluded (red icon)
You can also just right click on your folder and select Mark Directory As > Excluded
.
Excluded folders (shown as rootExcluded) are ones that IntelliJ IDEA "partially ignores". Very limited coding assistance is provided for files in excluded folders. Classes contained in excluded folders don't appear in code completion suggestion lists, references to such classes are shown in the editor as unresolved. When searching, IntelliJ IDEA doesn't look in excluded folders, etc.
Source
Note: See the answer by Nader Hadji Ghanbari for another approach using Scopes.
By defining a Scope when searching, you can include/exclude arbitrary files/folders from that scope.
One way to achieve your requirement (excluding files and folders from a search) is to define a custom scope. This is specifically useful because sometimes you just want to exclude a folder from your search and not from the whole project.
Follow these steps:
Edit
-> Find
-> Find in path
or press Ctrl+Shift+F.
Choose Custom
in the Scope
section and then choose <unknown scope>
+
button to add a new local
custom scopeinclude recursively
and then exclude one by one by choosing exclude
or exclude recursively
.Note that you can even include or exclude libraries your project is dependent on.
Scope
section in Find in Path
dialog.You can check the JetBrains docs on Scopes for more info. Scopes can be used not only when searching but also in a bunch of other use cases in IntelliJ IDEA.
You can use Patterns to define a scope which makes them even more powerful and future proof.
using patterns is another way to exclude files and folders. For instance file:src/main/java//*&&!file:src/main/java/my//*
will exclude all files in my
folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With