From f0fe558f38aca040f00776575983cacbe9b7d011 Mon Sep 17 00:00:00 2001 From: Antoni Stevent Date: Wed, 2 Jun 2021 20:00:43 +0200 Subject: [PATCH] Add up/right/left/down arrow keymaps, similar to kakoune --- helix-term/src/keymap.rs | 43 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs index de569656f..b7011c926 100644 --- a/helix-term/src/keymap.rs +++ b/helix-term/src/keymap.rs @@ -35,10 +35,10 @@ use std::collections::HashMap; // f = find_char() // g = goto (gg, G, gc, gd, etc) // -// h = move_char_left(n) -// j = move_line_down(n) -// k = move_line_up(n) -// l = move_char_right(n) +// h = move_char_left(n) || arrow-left = move_char_left(n) +// j = move_line_down(n) || arrow-down = move_line_down(n) +// k = move_line_up(n) || arrow_up = move_line_up(n) +// l = move_char_right(n) || arrow-right = move_char_right(n) // : = command line // ; = collapse selection to cursor // " = use register @@ -128,6 +128,24 @@ pub fn default() -> Keymaps { key!('k') => commands::move_line_up, key!('l') => commands::move_char_right, + KeyEvent { + code: KeyCode::Left, + modifiers: KeyModifiers::NONE + } => commands::move_char_left as Command, + KeyEvent { + code: KeyCode::Down, + modifiers: KeyModifiers::NONE + } => commands::move_line_down, + KeyEvent { + code: KeyCode::Up, + modifiers: KeyModifiers::NONE + } => commands::move_line_up, + KeyEvent { + code: KeyCode::Right, + modifiers: KeyModifiers::NONE + } => commands::move_char_right, + + key!('t') => commands::find_till_char, key!('f') => commands::find_next_char, key!('T') => commands::till_prev_char, @@ -269,6 +287,23 @@ pub fn default() -> Keymaps { key!('k') => commands::extend_line_up, key!('l') => commands::extend_char_right, + KeyEvent { + code: KeyCode::Left, + modifiers: KeyModifiers::NONE + } => commands::move_char_left as Command, + KeyEvent { + code: KeyCode::Down, + modifiers: KeyModifiers::NONE + } => commands::move_line_down, + KeyEvent { + code: KeyCode::Up, + modifiers: KeyModifiers::NONE + } => commands::move_line_up, + KeyEvent { + code: KeyCode::Right, + modifiers: KeyModifiers::NONE + } => commands::move_char_right, + key!('w') => commands::extend_next_word_start, key!('b') => commands::extend_prev_word_start, key!('e') => commands::extend_next_word_end,