Martin Tlachač
Martin Tlachač

Reputation: 409

How can I make logical AND in intellij idea search

Sometimes I would find very useful to search (ctrl - shift - f) in intellij idea all files containing "string1" AND "string2".

Is this somehow possible?

Upvotes: 0

Views: 843

Answers (2)

glytching
glytching

Reputation: 47865

You could use a regex search. Here's an example:

enter image description here

This regex: (?s)^(?=.*?string1)(?=.*?string2) matches any file that contains both strings, it doesn't care about order (i.e. which string comes first in a given file) nor does it care about the number of strings you search for so you can add additional criteria by appending another (?=.*?_your_text_here).

In addition, it can be easily extended to cover logical ORs ...

(?s)^(?=.*?string1)|(?=.*?string2)

Upvotes: 2

Meo
Meo

Reputation: 12491

Search for string1, then for string2 while using scope Files in Previous Search Result enter image description here

Upvotes: 5

Related Questions