Search code examples
pycharmmacroskeyboard-shortcuts

Stop PyCharm From Auto-Inserting Selected Text to Search Box


When using a hotkey to perform a search, PyCharm will automatically paste selected text into the search box.

How can I stop this behavior so that when I open the search box with a selection made, it isn't auto pasted into the search box?

As an example, this is a snapshot where I had source code highlighted and opened the search box. You can see that the selected text was automatically inserted into the search bar.

undesired behavior


Solution

  • Considering how PyCharm works the easiest way to do this is recording a macro and rebinding the Find Ctrl + F keyboard shortcut.

    If you press Ctrl + Shift + A or go to File > Settings > Keymap and carefully examine all the Find actions they all have the functionality of pasting the selected text into the search box. That can't be changed. So the alternative is recording a marco that combines the Ctrl + F action with a backspace to clear the search box.

    screenshot of find actions dialogue

    It's an easy 2 step process, go to Edit > Macros > Start Macro Recording having some text selected, press the Ctrl + F and backspace and again go to Edit > Macros > Stop Macro Recording. Save the marco and give it a name.

    Next rebind the Ctrl + F keyboard shortcut to your macro by going to File > Settings > Keymap > Macros.

    screenshot keymap dialogue

    This gives the find functionality exactly as requested in the question.