Community
    • Login

    Find selected text via F3?

    Scheduled Pinned Locked Moved General Discussion
    7 Posts 3 Posters 749 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.
    • vanowmV
      vanowm
      last edited by

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

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • Stefan PendlS
        Stefan Pendl
        last edited by

        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
        • PeterJonesP
          PeterJones @vanowm
          last edited by

          @vanowm ,

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

          vanowmV 1 Reply Last reply Reply Quote 0
          • vanowmV
            vanowm @PeterJones
            last edited by

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

            PeterJonesP 1 Reply Last reply Reply Quote 0
            • PeterJonesP
              PeterJones @vanowm
              last edited by PeterJones

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

              vanowmV 1 Reply Last reply Reply Quote 1
              • vanowmV
                vanowm @PeterJones
                last edited by

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

                  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
                  • First post
                    Last post
                  The Community of users of the Notepad++ text editor.
                  Powered by NodeBB | Contributors