From ccf296c57519a4f1a9c67b074a34ee9eb46d1ef7 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Tue, 20 Sep 2022 22:52:16 +0800 Subject: [PATCH] Keep arrow and special keys in insert Advanced users won't need it and is useful for beginners. Revert part of #3671. --- book/src/keymap.md | 42 ++++++++++++-------------------- helix-term/src/keymap/default.rs | 11 +++++++++ 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/book/src/keymap.md b/book/src/keymap.md index 99b0f0ba8c19..6da0185beb1b 100644 --- a/book/src/keymap.md +++ b/book/src/keymap.md @@ -335,32 +335,22 @@ experience. | `Backspace`, `Ctrl-h` | Delete previous char | `delete_char_backward` | | `Delete`, `Ctrl-d` | Delete next char | `delete_char_forward` | -However, if you really want navigation in insert mode, this is supported. An -example config that gives the ability to use arrow keys while still in insert -mode: - -```toml -[keys.insert] -"up" = "move_line_up" -"down" = "move_line_down" -"left" = "move_char_left" -"right" = "move_char_right" -"C-b" = "move_char_left" -"C-f" = "move_char_right" -"A-b" = "move_prev_word_end" -"C-left" = "move_prev_word_end" -"A-f" = "move_next_word_start" -"C-right" = "move_next_word_start" -"A-<" = "goto_file_start" -"A->" = "goto_file_end" -"pageup" = "page_up" -"pagedown" = "page_down" -"home" = "goto_line_start" -"C-a" = "goto_line_start" -"end" = "goto_line_end_newline" -"C-e" = "goto_line_end_newline" -"A-left" = "goto_line_start" -``` +### Insert Mode (beginners) + +These keys are not recommended, it is for those who do not read documentations. + +| Key | Description | Command | +| ----- | ----------- | ------- | +| `Up` | Move to previous line | `move_line_up` | +| `Down` | Move to next line | `move_line_down` | +| `Left` | Backward a char | `move_char_left` | +| `Right` | Forward a char | `move_char_right` | +| `Ctrl-Left` | Backward a word | `move_prev_word_end` | +| `Ctrl-Right` | Forward a word | `move_next_word_start` | +| `PageUp` | Move one page up | `page_up` | +| `PageDown` | Move one page down | `page_down` | +| `Home` | Move to line start | `goto_line_start` | +| `End` | Move to line end | `goto_line_end_newline` | ## Select / extend mode diff --git a/helix-term/src/keymap/default.rs b/helix-term/src/keymap/default.rs index f07d4028ccde..f6bf4e41a22b 100644 --- a/helix-term/src/keymap/default.rs +++ b/helix-term/src/keymap/default.rs @@ -360,6 +360,17 @@ pub fn default() -> HashMap { "C-x" => completion, "C-r" => insert_register, + + "up" => move_line_up, + "down" => move_line_down, + "left" => move_char_left, + "right" => move_char_right, + "C-left" => move_prev_word_end, + "C-right" => move_next_word_start, + "pageup" => page_up, + "pagedown" => page_down, + "home" => goto_line_start, + "end" => goto_line_end_newline, }); hashmap!( Mode::Normal => Keymap::new(normal),