Escape should exit search mode (Vim-like behavior) #4

Closed
opened 2026-04-19 22:38:52 -07:00 by nelsong6 · 1 comment
nelsong6 commented 2026-04-19 22:38:52 -07:00 (Migrated from github.com)

Currently Escape in search mode with a non-empty query clears the query but keeps us in search mode (step 2 of the unwind cascade in CLAUDE.md's "Back-out / unwind cascade" section).

Vim's Escape exits insert mode — the free-typing mode. fzt's search mode is the analogous free-typing mode. Escape should exit it into normal mode, so the muscle memory carries over.

Proposed change

In search mode, Escape should transition to normal mode (cursor on tree). The query could be preserved — Vim's Escape doesn't wipe the line you just typed.

This would reorder the unwind cascade so the mode transition happens before query clearing. Subsequent Escape presses in normal mode would still unwind query → scope → context → cancel.

Questions to resolve

  • Should the query be preserved on Escape-from-search, or cleared? Vim preserves the inserted text; preserving the query keeps the filtered view stable while the user navigates with hjkl.
  • Does this conflict with the existing "Escape on non-empty query clears query" behavior? It replaces it — clearing becomes a second Escape press (or Shift+Backspace, which already resets to home).

Related: the existing backtick (`) binding already does "enter normal mode" from search, so this is adding an alternative entry point that matches the Vim convention.

Currently Escape in search mode with a non-empty query clears the query but keeps us in search mode (step 2 of the unwind cascade in CLAUDE.md's "Back-out / unwind cascade" section). Vim's Escape exits insert mode — the free-typing mode. fzt's search mode is the analogous free-typing mode. Escape should exit it into normal mode, so the muscle memory carries over. ## Proposed change In search mode, Escape should transition to normal mode (cursor on tree). The query could be preserved — Vim's Escape doesn't wipe the line you just typed. This would reorder the unwind cascade so the mode transition happens before query clearing. Subsequent Escape presses in normal mode would still unwind query → scope → context → cancel. ## Questions to resolve - Should the query be preserved on Escape-from-search, or cleared? Vim preserves the inserted text; preserving the query keeps the filtered view stable while the user navigates with hjkl. - Does this conflict with the existing "Escape on non-empty query clears query" behavior? It replaces it — clearing becomes a second Escape press (or Shift+Backspace, which already resets to home). Related: the existing backtick (\`) binding already does "enter normal mode" from search, so this is adding an alternative entry point that matches the Vim convention.
nelsong6 commented 2026-04-19 22:41:05 -07:00 (Migrated from github.com)

Wrong repo — the search-mode Escape behavior is implemented in the engine at core/input.go::HandleSearchKey. Refiling on nelsong6/fzt.

Wrong repo — the search-mode Escape behavior is implemented in the engine at [core/input.go::HandleSearchKey](https://github.com/nelsong6/fzt/blob/main/core/input.go). Refiling on nelsong6/fzt.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
romaine-life/fzt-terminal#4
No description provided.