• Login
Community
  • Login

Find selected text via F3?

Scheduled Pinned Locked Moved General Discussion
7 Posts 3 Posters 770 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V
    vanowm
    last edited by Oct 2, 2021, 1:41 AM

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

    P 1 Reply Last reply Oct 2, 2021, 4:14 PM Reply Quote 0
    • S
      Stefan Pendl
      last edited by Oct 2, 2021, 11:54 AM

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

      1 Reply Last reply Reply Quote 1
      • P
        PeterJones @vanowm
        last edited by Oct 2, 2021, 4:14 PM

        @vanowm ,

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

        V 1 Reply Last reply Oct 2, 2021, 4:37 PM Reply Quote 0
        • V
          vanowm @PeterJones
          last edited by Oct 2, 2021, 4:37 PM

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

          P 1 Reply Last reply Oct 2, 2021, 4:59 PM Reply Quote 0
          • P
            PeterJones @vanowm
            last edited by PeterJones Oct 2, 2021, 5:00 PM Oct 2, 2021, 4:59 PM

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

            V 1 Reply Last reply Oct 2, 2021, 7:07 PM Reply Quote 1
            • V
              vanowm @PeterJones
              last edited by Oct 2, 2021, 7:07 PM

              @PeterJones Yes, it is almost works as I’d like, except when there is no selection it automatically selects first word next to cursor.

              1 Reply Last reply Reply Quote 0
              • V
                vanowm
                last edited by vanowm Oct 3, 2021, 5:13 PM Oct 3, 2021, 5:10 PM

                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

                1 Reply Last reply Reply Quote 1
                7 out of 7
                • First post
                  7/7
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors