ProgerXP / Notepad2e

Word highlighting, simultaneous editing, split views, math evaluation, un/grep, comment reformatting, UAC elevation, complete regexps (PCRE), Lua lexers, DPI awareness and more (XP+)
Other
370 stars 52 forks source link

Hotkeys to search on the current line #435

Open ProgerXP opened 1 year ago

ProgerXP commented 1 year ago

This is like f F t T in Vim.

Hotkeys except F1 should be currently available. Unbind F1 from About.

Shift/Alt/F1, Shift/Alt+F2 pressed when the text area is focused move focus to an invisible text input. If the document is empty, they do nothing (as Alt+F and others).

  1. When a key was pressed while this input is focused and the input's new value is not empty, perform the operation (typically user would input a single symbol, but it's possible to enter an arbitrary string with the usual Alt+V hotkey even though the caret is not visible on screen).
  2. When a hotkey (Shift/Alt/F1, Shift/Alt+F2) was pressed while this input is focused, if its current value is empty then do nothing (retain focus there), else perform the operation. This way, because input value is retained for the lifetime of the process, pressing the hotkey twice invokes operation using the previously entered search text.

Operation depends on the hotkey that was pressed either when entering this mode if anything was input (1), or hotkey pressed when leaving it without inputting (2, in this case the first hotkey pressed to focus the input is irrelevant). All operations perform the case-sensitive search for the entered string on the current line; hotkeys differ in the search direction used and positioning of caret and selection. In case no match was found, the operation ends without changing anything.

Hotkey Direction Caret Selection
F1 Forward Before match Empty
Shift+F1 Backward Before match Empty
Alt+F1 Forward After match Empty
Shift+Alt+F1 Backward After match Empty
Alt+F2 Forward After match Match selected
Shift+Alt+F2 Backward Before match Match selected

If main window loses focus, this mode ends (focus returns to the text area). Same happens if the document is changed, a dialog is opened or Escape is pressed.