18

In Notepad++, when you do Search -> Find, it automatically populates the "Find what:" field according to the behavior below (per the online documentation - emphasis mine)...

In the Find what field, type the text you want to find. This is automatically filled with the current selected text, or the word under the caret, or the last searched pattern, when the Find dialog is opened.

Is there a way to change or disable this behavior? I would prefer that it come up empty. I don't mind the last searched pattern as a reasonable default, but it drives me nuts when it keeps changing the search value by automatically selecting a word next to the cursor.

I've done quite a bit of digging (settings, help, web searches, etc.) and can't find a way to turn this off.

Devon Biere
  • 2,992
  • 1
  • 23
  • 32
  • 1
    There is a feature request to make this optional: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/3243 – ocroquette Jul 23 '19 at 06:02

2 Answers2

5

There is no standard option to do this but you can achieve it by:

  1. The harder way: download N++ sources and make your own N++ build with desired modification

  2. The easier way: using AutoHotKey tool, capture Ctrl+F shortcut (with condition only if N++ window is active, see #IfWinActive directive ) so when it is pressed, send keys Ctrl+F, Backspace. Similar for Ctrl+H (Replace)

The AHK macros which work for me are:

SetTitleMatchMode, RegEx

;--------------------------------- Hotkeys for Notepad++ only
#IfWinActive ahk_class Notepad\+\+

; present 'find' dialog with empty field
^f::Send ^f{Backspace}  

; present 'replace' dialog with empty field
^h::Send ^h{Backspace}  

; another example: close document with either ^F4 or ^W
^F4::Send ^w

#IfWinActive

For details regarding AutoHotkey macro setup, please check steps 1-5 in this answer.

Community
  • 1
  • 1
miroxlav
  • 11,796
  • 5
  • 58
  • 99
  • 1
    That's too bad. I love notepad++ to death but this "feature" really slows me down.. – Alkanshel Sep 30 '16 at 18:43
  • The problem here is that when N++ selects the text, it moves the internal pointer to the end of the selected text, which means that anything you search for won't included the previously-selected text. It makes it harder to deal with regular expression searches. That's why a simple backspace won't work... the pointer is already moved regardless of what's in the find dialog. – pbarney Jun 30 '20 at 14:34
5

This problem has been fixed since 2019. I downloaded version 7.8.8 and found an option to turn this feature off in Settings > Preferences > MISC > Don't fill find field in Find dialog with selected word.

Ray Chakrit
  • 404
  • 5
  • 7
  • Thank you! It has indeed... https://github.com/notepad-plus-plus/notepad-plus-plus/commit/7a1096de5b3618bc3e6611e6c25caac952d41ae2 and https://github.com/notepad-plus-plus/notepad-plus-plus/issues/3243 – Devon Biere Jul 24 '20 at 18:48
  • If some keyboard shortcuts no longer work after upgrading to a newer version, just look in Settings>Shortcut Mapper. – Ray Chakrit Jul 28 '20 at 11:36
  • 5
    It seems this option has moved - it's now in Settings > Preferences > Searching – Grid Trekkor Dec 15 '20 at 17:53