diff options
author | Mike Pastore <mwpastore@users.noreply.github.com> | 2024-02-26 06:01:14 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-26 12:01:14 +0000 |
commit | 43a1d3a862ad486a27287b178c572ccab0f0e46c (patch) | |
tree | bc161b092fdc35f409b20118429cfd4209d97b05 | |
parent | d7582b62fd74222fe936edbbd47d17f5c18c0cb4 (diff) |
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.)
-rw-r--r-- | atuin/src/command/client/search/interactive.rs | 18 |
1 files changed, 18 insertions, 0 deletions
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; } |