Setting to close Find window after initiating search?
-
When I want to search, I press CTRL+F and enter some text then click the Find Next button to begin the search. The search dialog stays open. Is there any setting to close that window when the search begins. I usually just use F3 after the initial search to find additional occurrences.
I realize there are other posts here for people who want to keep it open while searching, but I was just wondering if by chance there was an option to control this behavior.
-
Probably the quickest way is to press
Esc
-
Ok, thanks. I was hoping for an option to close it after the initial Find Next button was clicked.
-
Probably the desire for this is that the Find window takes up a huge amount of space?
-
I just don’t need it at that point since I always do F3 after the initial entry of the search text. For me it’s just an unnecessary extra keystroke to remove it after starting the search.
-
If your search term is the word at the caret or some small bit of text that you could select first, you can avoid the _Find window entirely by executing Select and Find Next, which by default is Ctrl+F3. Just a thought.
-
That’s neat – Although it’s not always the case for my search term, I might be able to get used to that in those cases.
-
I too am really annoyed by this. I use the keyboard when using Notepad because it is a text editor. Everytime I do a search I get a popup window which doesn’t automatically close after I press the ENTER/RETURN key.
This should be very easy to implement right? A simple setting which auto closes the popup window which is obscuring the text you are editing.
I’m aware I can press the ESC key to close the window, but it happening automatically would greatly improve the fluidity of using Notepad. -
The large Find window IS annoying on a single monitor setup (presume that is what yours is). On multiple monitors, it isn’t so bad, you can have Notepad++ maximized on one monitor and put the find window on the/an adjacent monitor.
Have you tried the “reduced size” Find window? It looks like this:
and the size is toggled by the button I’ve highlighted in yellow; same relative location for the button in the larger version of the window, but it has a
^
caption in that case.
Another interesting idea would be if the Find window would go “roving” after each match is found…if it needs to. What this means is, if the text of the match found appears under the Find window, the window should reposition itself somewhere else, allowing you to see your matched text.
-
The desired behavior can be scripted if one wants to use a plugin (PythonScript) to achieve the goal.
I call the script
FindNextClosesFindWindow.py
and here is its listing:# -*- coding: utf-8 -*- from __future__ import print_function # see https://community.notepad-plus-plus.org/topic/19844/setting-to-close-find-window-after-initiating-search from Npp import * import platform from ctypes import (WinDLL, WINFUNCTYPE) from ctypes.wintypes import (HWND, UINT, INT, WPARAM, LPARAM) #------------------------------------------------------------------------------- user32 = WinDLL('user32') GWL_WNDPROC = -4 # used to set a new address for the window procedure LRESULT = LPARAM WndProcType = WINFUNCTYPE( LRESULT, # return type HWND, UINT, WPARAM, LPARAM # function arguments ) running_32bit = platform.architecture()[0] == '32bit' SetWindowLong = user32.SetWindowLongW if running_32bit else user32.SetWindowLongPtrW SetWindowLong.restype = WndProcType SetWindowLong.argtypes = [ HWND, INT, WndProcType ] SendMessageW = user32.SendMessageW SendMessageW.restype = LRESULT SendMessageW.argtypes = [ HWND, UINT, WPARAM, LPARAM ] WM_COMMAND = 0x111 WM_CLOSE = 0x10 IDOK = 1 # 'Find Next' button in Find dialog # for the following see https://github.com/notepad-plus-plus/notepad-plus-plus/blob/3c9d58176b0fd890d26e96d0208d2d981f1544e4/PowerEditor/src/ScitillaComponent/FindReplaceDlg_rc.h#L1 IDC_FINDNEXT = 1723 # 'Find down-arrow' button in Find dialog IDC_FINDPREV = 1721 # 'Find up-arrow' button in Find dialog #------------------------------------------------------------------------------- class FNCFW(object): def __init__(self): for try_count in (1, 2): if try_count == 2: notepad.menuCommand(MENUCOMMAND.SEARCH_FIND) for find_window_tab_caption in [ u'Find', u'Replace', u'Find in Files', u'Find in Projects', u'Mark' ]: self.find_window_hwnd = user32.FindWindowExW(None, None, u'#32770', find_window_tab_caption) if self.find_window_hwnd: self.new_find_wnd_proc_hook_for_SetWindowLong = WndProcType(self.new_find_wnd_proc_hook) self.orig_find_wnd_proc = SetWindowLong(self.find_window_hwnd, GWL_WNDPROC, self.new_find_wnd_proc_hook_for_SetWindowLong) if try_count == 2: self.close_find_window() return def new_find_wnd_proc_hook(self, hwnd, msg, wParam, lParam): orig_wnd_proc_ret_val = self.orig_find_wnd_proc(hwnd, msg, wParam, lParam) if msg == WM_COMMAND and wParam in [ IDC_FINDNEXT, IDC_FINDPREV, IDOK ]: self.close_find_window() return orig_wnd_proc_ret_val def close_find_window(self): SendMessageW(self.find_window_hwnd, WM_CLOSE, 0, 0) #------------------------------------------------------------------------------- if __name__ == '__main__': try: fncfw except NameError: fncfw = FNCFW()
It can be set up in startup.py to run automatically when Notepad++ starts via these two lines:
import FindNextClosesFindWindow fncfw = FindNextClosesFindWindow.FNCFW()
-