mouwsy
mouwsy

Reputation: 1933

Find in files of multiple projects in PyCharm

How can I use the option "Find in files" (Ctrl + Shift + F or ⇧⌘F) for multiple or all projects in PyCharm? For example if I have project "foo" and project "bar", how can I use "Find in files" when I am in the project "foo" and also want to see the search results of "bar"?

Upvotes: 2

Views: 513

Answers (1)

bad_coder
bad_coder

Reputation: 12910

How can I use the option "Find in files" (Ctrl+Shift+F or ⇧⌘F) for multiple or all projects in PyCharm?

In the context of PyCharm what is called "a project" is a base directory containing an .idea folder that PyCharm generates when you create a new project.

When you use "Find in Files" what is searched are the files in the projects (notice the plural) currently opened in the "Project tool window" (Alt + 1). This corresponds to the projects listed in File > Settings > Project > Project Dependencies or the file .idea\misc.xml of the first project you opened in that PyCharm window.

For example, in the screenshot two projects are opened (this is done by using Attach, see "Open multiple projects" ) in the Project tool window and both are searched (the screenshots were edited for a side-by-side view).

enter image description here

This way running "Find in Files" shows occurrences in both projects.

enter image description here

if I have project "foo" and project "bar", how can I use "Find in files" when I am in the project "foo" and also want to see the search results of "bar"

The simple answer is: Open both projects in the same PyCharm window.



But lets rephrase the original question in its more general sense:

Is it possible to search several projects using "Find in Files" if they are not open in the current window?

The answer is: No.

PyCharm provides several different search functions with its "Find in Files" like "Custom Scopes" (and others like Search everywhere). But none of them provide the functionality to simultaneously search multiple projects that aren't currently opened. The reason for this might not be intuitive, but notice these search functions can also include searching in "External Libraries", "Datas Sources", "Scratches and Consoles", etc... So to provide these contexts PyCharm has to open the individual Projects and do some processing. It's more than just a textual search in files and directories.

So if what you are looking for is just "full-text-search" in a chosen list of directories without opening them in the PyCharm Project tool window, the easiest way (what I use) is using the OS's search function or a different IDE (like Notepad++) that have that kind of search functionality.

(I tried finding a PyCharm plugin but apparently at the moment there is none that integrates that kind of search function.)

Upvotes: 3

Related Questions