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.)
This commit is contained in:
Mike Pastore 2024-02-26 06:01:14 -06:00 committed by GitHub
parent d7582b62fd
commit 43a1d3a862
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;
}