Skip to content

Commit

Permalink
feat: add CTRL+[ binding as <Esc> alias
Browse files Browse the repository at this point in the history
in Vim/Neovim there is alias for `<Esc>` mapping -- `<C-[>`. it is useful if
your `<Esc>` key is hard to hit on your keyboard.

for reference:

    https://vimhelp.org/insert.txt.html#i_CTRL-%5B
    https://neovim.io/doc/user/insert.html#i_CTRL-%5B
  • Loading branch information
liljaylj committed Feb 27, 2024
1 parent cc96486 commit 2e86533
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion atuin/src/command/client/search/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ impl State {
KeyCode::Esc if !(self.tab_index == 0 && self.keymap_mode == KeymapMode::VimInsert) => {
return Self::handle_key_exit(settings);
}
KeyCode::Char('[')
if ctrl && !(self.tab_index == 0 && self.keymap_mode == KeymapMode::VimInsert) =>
{
return Self::handle_key_exit(settings);
}
KeyCode::Tab => {
return InputAction::Accept(self.results_state.selected());
}
Expand Down Expand Up @@ -320,7 +325,7 @@ impl State {
_ => {}
},
KeymapMode::VimInsert => {
if input.code == KeyCode::Esc {
if input.code == KeyCode::Esc || (ctrl && input.code == KeyCode::Char('[')) {
self.set_keymap_cursor(settings, "vim_normal");
self.keymap_mode = KeymapMode::VimNormal;
return InputAction::Continue;
Expand Down

0 comments on commit 2e86533

Please sign in to comment.