mirror of
https://github.com/atuinsh/atuin.git
synced 2024-11-22 08:13:57 +01:00
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:
parent
d7582b62fd
commit
43a1d3a862
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user