Skip to content
Advertisement

Change default scope for “find usages” in PyCharm

Somehow my PyCharm’s “Find Usages” scope gets changed and now it only searches in “Scratches and Consoles”.

It used to be that when I typed ⌘B, PyCharm would go to the definition or usages of the object.

But now I get this popup that says usages are out of scope 'Scratches and Consoles', and I have to press ⌥⌘F7 to get to search in project files.

usages are out of scope 'Scratches and Consoles'

I tried clicking on the settings wrench and changing the scope but it does not persist.

Advertisement

Answer

There are a number of undocumented rules to this that can only be verified by trying it out:

  1. If you have 2 PyCharm windows open (meaning 2 different projects simultaneously open in 2 different windows) you can only have 1 settings dialog (Ctrl + Alt + Shift + F7 or ⌥⌘F7 on Mac) open simultaneously. Meaning if you change the setting in one window while the dialog is open in the other, the same setting is changed in both windows.

  2. If you only have the above mentioned settings dialog open in 1 window, the setting can be selected differently for both windows.

Now to the question,

  1. If you close your current window the last find setting you chose will be saved, and it will persist when you later reopen that window/project and be used for searches. But there is one exception to this, if your last setting before closing the window was a saved costum scope then when you reopen the window the search setting will have reverted to default.

    Here comes 1 important subtlety, after reopening the window if you try “Find usages” (Alt + F7 or ⌥⌘F7) the search will indeed use that last setting before you closed the window (you can see it in the search title window). But if you again press (Ctrl + Alt + Shift + F7 or ⌥⌘F7 on Mac) or the cog in the find settings, the setting you’ll be shown is most times the default (sometimes not, but this behavior is not clearly consistent).

    Meaning, it’s not always consistent what setting is first shown in the below dialog after you reopen the IDE.

    enter image description here

  2. The problem you are describing should not be an issue. If you close the window the setting should persist. If you try opening the setting again most times you’ll be offered with the default (after reopening the window) or your last choice if you changed it after opening the window.

    There is, however, no way to change the default (this is probably to protect inexperienced users from configuring an IDE default search setting that would be difficult to revert). Meaning the first time you open the IDE if the setting doesn’t revert to default automatically you’ll have to set it manually but just that once.

(In these cases invalidating caches is frequently a good choice, if the cache becomes stale you can start having inexplicable results in search.)

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement