From 43a1d3a862ad486a27287b178c572ccab0f0e46c Mon Sep 17 00:00:00 2001 From: Mike Pastore Date: Mon, 26 Feb 2024 06:01:14 -0600 Subject: [PATCH] feat: Add '/', '?', and 'I' bindings to vim-normal mode (#1760) Add 'I' binding to vim-normal mode (a la 'A' introduced in #1697) to jump into vim-insert mode at the beginning of the search input. Also add '/' and '?' bindings to vim-normal mode to clear the search input and jump into vim-insert mode. This mimics the UX in e.g. `set -o vi` (bash) or `bindkey -v` (zsh) mode when you are using 'k' and 'j' to browse history lines and can type '/' or '?' to start a new search. (In a perfect world it would target the search in the forward or backward range starting at your current position in the history, but this is a reasonable first step.) --- atuin/src/command/client/search/interactive.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/atuin/src/command/client/search/interactive.rs b/atuin/src/command/client/search/interactive.rs index 8c6a672b..bd25cf7b 100644 --- a/atuin/src/command/client/search/interactive.rs +++ b/atuin/src/command/client/search/interactive.rs @@ -265,6 +265,18 @@ impl State { // First handle keymap specific keybindings. match self.keymap_mode { KeymapMode::VimNormal => match input.code { + KeyCode::Char('/') if !ctrl => { + self.search.input.clear(); + self.set_keymap_cursor(settings, "vim_insert"); + self.keymap_mode = KeymapMode::VimInsert; + return InputAction::Continue; + } + KeyCode::Char('?') if !ctrl => { + self.search.input.clear(); + self.set_keymap_cursor(settings, "vim_insert"); + self.keymap_mode = KeymapMode::VimInsert; + return InputAction::Continue; + } KeyCode::Char('j') if !ctrl => { return self.handle_search_down(settings, true); } @@ -296,6 +308,12 @@ impl State { self.keymap_mode = KeymapMode::VimInsert; return InputAction::Continue; } + KeyCode::Char('I') if !ctrl => { + self.search.input.start(); + self.set_keymap_cursor(settings, "vim_insert"); + self.keymap_mode = KeymapMode::VimInsert; + return InputAction::Continue; + } KeyCode::Char(_) if !ctrl => { return InputAction::Continue; }