Find selected text via F3?



  • Hello.
    Is there a way configure NPP to search for selected text when F3 is pressed without need open search dialog?
    Thank you.



  • Use [Ctrl]+[F3] to search for selected text.
    See all search shortcuts in the search menu of NPP.



  • @vanowm ,

    Settings > Shortcut Mapper allows you to change shortcuts. As @Stefan-Pendl said, that feature defaults to Ctrl+F3



  • @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.



  • @vanowm ,

    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.



  • 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:

    4d37ed6d-5f17-4313-a646-bcd0235bfffb-image.png

    Restart NPP, than in Settings -> Shortcut mapper -> Plugin commands search for your script’s filename:

    3726c612-81dd-4f9b-838d-ed8ca2c5060e-image.png


Log in to reply