Find selected text via F3?
Is there a way configure NPP to search for selected text when F3 is pressed without need open search dialog?
Stefan Pendl last edited by
Use [Ctrl]+[F3] to search for selected text.
See all search shortcuts in the search menu of NPP.
PeterJones last edited by
Settings > Shortcut Mapper allows you to change shortcuts. As @Stefan-Pendl said, that feature defaults to
@PeterJones Unfortunately it doesn’t seem to allow 2 actions for the same shortcut…I’d like to use F3 for find next and if I select different text and press F3 again it would find the next instance of selected text.
PeterJones last edited by PeterJones
That’s not the way that the Scintilla IP that Notepad++ uses works. The key will do one thing – either “Find Next” or “Select and Find Next”.
But if you remove the shortcut for Find Next and change Select and Find Next to F3, then it will likely come close to what you want… because when you hit it a second time, whether the old word is still in the buffer for searching, or whether you have selected new text since the last instance of Select and Find Next, when you hit Select and Find Next again, it will usually find what you expect, based on my understanding of your expectations.
@PeterJones Yes, it is almost works as I’d like, except when there is no selection it automatically selects first word next to cursor.
vanowm last edited by vanowm
Here is a Python script that does exactly as I wanted: if text selected - search for selected text, if nothing selected - execute “find next”
if editor.getSelText() == "": notepad.menuCommand(MENUCOMMAND.SEARCH_FINDNEXT) else: notepad.menuCommand(MENUCOMMAND.SEARCH_SETANDFINDNEXT)
To bind this to
F3, first add the script as Menu item in PythonScript config:
Restart NPP, than in
Settings -> Shortcut mapper -> Plugin commandssearch for your script’s filename: