Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Notepad2: F3 to search the selected text


  • Please log in to reply
No replies to this topic
heilong
  • Members
  • 9 posts
  • Last active: Oct 08 2015 05:17 PM
  • Joined: 04 Aug 2013

In most editors F3 finds next match for the previous "Find...", in some editors (e.g. FlashDevelop) selecting some text then pressing F3 finds the selected text (starts a new find) rather than continuing the previous search (if any). I like that behavior, so here's a little script that makes Notepad2-mod search for selected text on F3, or find next match if there's no text selected. I don't know any better way of reliably check if there's any text selected, but it seems to work ok on my (rather fast) computer. If it's not stable, the value 0.05 (50 ms) for ClipWait should be increased - however increasing the wait will slow down the response when no text is selected.

#if WinActive("ahk_exe Notepad2.exe")
    F3::
        ClipSaved := ClipboardAll
        Clipboard :=
        Send ^c
        ClipWait, 0.05
        Send % (Clipboard ? "^{F3}" : "{F3}")
        Clipboard := ClipSaved
        ClipSaved :=
        return
#if