on master help sign in
Keep arrow and special keys in insert (#3915)

* Keep arrow and special keys in insert Advanced users won't need it and is useful for beginners. Revert part of #3671. * Change text for insert mode section Co-authored-by: Blaž Hrastnik <blaz@mxxn.io> * Remove ctrl-up/down in insert * Reorganize insert keys and docs * Improve page up experience on last tutor The last tutor page can page down multiple times and it will break the heading on the 80x24 screen paging when reaching the last page, this keeps the style the same and make sure page up and down won't break it. Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>

commit3d59d3f8be214ddb5b75d6a9df5f0ea1fff5f31c authorIvan Tham <pickfire@riseup.net> dateMon 3 Oct 2022, 23:08 (4 years ago) parent1d8bb22
3 files changed+63−54
book/src/keymap.md+28−40 helix-term/src/keymap/default.rs+17−14 runtime/tutor+18
book/src/keymap.md+28−40
@@ -314,7 +314,7 @@ Mappings in the style of [vim-unimpaired](https://github.com/tpope/vim-unimpaire
314314| `[space` | Add newline above | `add_newline_above` |
315315| `]space` | Add newline below | `add_newline_below` |
316316
317−## Insert Mode
317+## Insert mode
318318
319319Insert mode bindings are somewhat minimal by default. Helix is designed to
320320be a modal editor, and this is reflected in the user experience and internal
@@ -323,45 +323,33 @@ escaping from insert mode to normal mode. For this reason, new users are
323323strongly encouraged to learn the modal editing paradigm to get the smoothest
324324experience.
325325
326−| Key | Description | Command |
327−| ----- | ----------- | ------- |
328−| `Escape` | Switch to normal mode | `normal_mode` |
329−| `Ctrl-x` | Autocomplete | `completion` |
330−| `Ctrl-r` | Insert a register content | `insert_register` |
331−| `Ctrl-w`, `Alt-Backspace`, `Ctrl-Backspace` | Delete previous word | `delete_word_backward` |
332−| `Alt-d`, `Alt-Delete`, `Ctrl-Delete` | Delete next word | `delete_word_forward` |
333−| `Ctrl-u` | Delete to start of line | `kill_to_line_start` |
334−| `Ctrl-k` | Delete to end of line | `kill_to_line_end` |
335−| `Ctrl-j`, `Enter` | Insert new line | `insert_newline` |
336−| `Backspace`, `Ctrl-h` | Delete previous char | `delete_char_backward` |
337−| `Delete`, `Ctrl-d` | Delete next char | `delete_char_forward` |
338−
339−However, if you really want navigation in insert mode, this is supported. An
340−example config that gives the ability to use arrow keys while still in insert
341−mode:
342−
343−```toml
344−[keys.insert]
345−"up" = "move_line_up"
346−"down" = "move_line_down"
347−"left" = "move_char_left"
348−"right" = "move_char_right"
349−"C-b" = "move_char_left"
350−"C-f" = "move_char_right"
351−"A-b" = "move_prev_word_end"
352−"C-left" = "move_prev_word_end"
353−"A-f" = "move_next_word_start"
354−"C-right" = "move_next_word_start"
355−"A-<" = "goto_file_start"
356−"A->" = "goto_file_end"
357−"pageup" = "page_up"
358−"pagedown" = "page_down"
359−"home" = "goto_line_start"
360−"C-a" = "goto_line_start"
361−"end" = "goto_line_end_newline"
362−"C-e" = "goto_line_end_newline"
363−"A-left" = "goto_line_start"
364−```
326+| Key | Description | Command |
327+| ----- | ----------- | ------- |
328+| `Escape` | Switch to normal mode | `normal_mode` |
329+| `Ctrl-s` | Commit undo checkpoint | `commit_undo_checkpoint` |
330+| `Ctrl-x` | Autocomplete | `completion` |
331+| `Ctrl-r` | Insert a register content | `insert_register` |
332+| `Ctrl-w`, `Alt-Backspace` | Delete previous word | `delete_word_backward` |
333+| `Alt-d`, `Alt-Delete` | Delete next word | `delete_word_forward` |
334+| `Ctrl-u` | Delete to start of line | `kill_to_line_start` |
335+| `Ctrl-k` | Delete to end of line | `kill_to_line_end` |
336+| `Ctrl-h`, `Backspace` | Delete previous char | `delete_char_backward` |
337+| `Ctrl-d`, `Delete` | Delete next char | `delete_char_forward` |
338+| `Ctrl-j`, `Enter` | Insert new line | `insert_newline` |
339+
340+These keys are not recommended, but are included for new users less familiar
341+with modal editors.
342+
343+| Key | Description | Command |
344+| ----- | ----------- | ------- |
345+| `Up` | Move to previous line | `move_line_up` |
346+| `Down` | Move to next line | `move_line_down` |
347+| `Left` | Backward a char | `move_char_left` |
348+| `Right` | Forward a char | `move_char_right` |
349+| `PageUp` | Move one page up | `page_up` |
350+| `PageDown` | Move one page down | `page_down` |
351+| `Home` | Move to line start | `goto_line_start` |
352+| `End` | Move to line end | `goto_line_end_newline` |
365353
366354## Select / extend mode
367355
helix-term/src/keymap/default.rs+17−14
@@ -343,24 +343,27 @@ pub fn default() -> HashMap<Mode, Keymap> {
343343 let insert = keymap!({ "Insert mode"
344344 "esc" => normal_mode,
345345
346− "backspace" => delete_char_backward,
347− "C-h" => delete_char_backward,
348− "del" => delete_char_forward,
349− "C-d" => delete_char_forward,
350− "ret" => insert_newline,
351− "C-j" => insert_newline,
352− "tab" => insert_tab,
353− "C-w" => delete_word_backward,
354− "A-backspace" => delete_word_backward,
355− "A-d" => delete_word_forward,
356− "A-del" => delete_word_forward,
357346 "C-s" => commit_undo_checkpoint,
347+ "C-x" => completion,
348+ "C-r" => insert_register,
358349
359− "C-k" => kill_to_line_end,
350+ "C-w" | "A-backspace" => delete_word_backward,
351+ "A-d" | "A-del" => delete_word_forward,
360352 "C-u" => kill_to_line_start,
353+ "C-k" => kill_to_line_end,
354+ "C-h" | "backspace" => delete_char_backward,
355+ "C-d" | "del" => delete_char_forward,
356+ "C-j" | "ret" => insert_newline,
357+ "tab" => insert_tab,
361358
362− "C-x" => completion,
363− "C-r" => insert_register,
359+ "up" => move_line_up,
360+ "down" => move_line_down,
361+ "left" => move_char_left,
362+ "right" => move_char_right,
363+ "pageup" => page_up,
364+ "pagedown" => page_down,
365+ "home" => goto_line_start,
366+ "end" => goto_line_end_newline,
364367 });
365368 hashmap!(
366369 Mode::Normal => Keymap::new(normal),
runtime/tutor+18
@@ -1054,6 +1054,24 @@ letters! that is not good grammar. you can fix this.
10541054
10551055
10561056
1057+=================================================================
1058+= =
1059+=================================================================
1060+
1061+
1062+
1063+
1064+
1065+
1066+
1067+
1068+
1069+
1070+
1071+
1072+
1073+
1074+
10571075=================================================================
10581076 This tutorial is still a work-in-progress.
10591077 More sections are planned.