Skip to content

Commit eaba244

Browse files
pickfirearchseer
authored and
Shekhinah Memmel
committed
Keep arrow and special keys in insert (helix-editor#3915)
* Keep arrow and special keys in insert Advanced users won't need it and is useful for beginners. Revert part of helix-editor#3671. * Change text for insert mode section Co-authored-by: Blaž Hrastnik <[email protected]> * 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 <[email protected]>
1 parent d335354 commit eaba244

File tree

3 files changed

+63
-54
lines changed

3 files changed

+63
-54
lines changed

book/src/keymap.md

+28-40
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ Mappings in the style of [vim-unimpaired](https://github.com/tpope/vim-unimpaire
316316
| `[space` | Add newline above | `add_newline_above` |
317317
| `]space` | Add newline below | `add_newline_below` |
318318

319-
## Insert Mode
319+
## Insert mode
320320

321321
Insert mode bindings are somewhat minimal by default. Helix is designed to
322322
be a modal editor, and this is reflected in the user experience and internal
@@ -325,45 +325,33 @@ escaping from insert mode to normal mode. For this reason, new users are
325325
strongly encouraged to learn the modal editing paradigm to get the smoothest
326326
experience.
327327

328-
| Key | Description | Command |
329-
| ----- | ----------- | ------- |
330-
| `Escape` | Switch to normal mode | `normal_mode` |
331-
| `Ctrl-x` | Autocomplete | `completion` |
332-
| `Ctrl-r` | Insert a register content | `insert_register` |
333-
| `Ctrl-w`, `Alt-Backspace`, `Ctrl-Backspace` | Delete previous word | `delete_word_backward` |
334-
| `Alt-d`, `Alt-Delete`, `Ctrl-Delete` | Delete next word | `delete_word_forward` |
335-
| `Ctrl-u` | Delete to start of line | `kill_to_line_start` |
336-
| `Ctrl-k` | Delete to end of line | `kill_to_line_end` |
337-
| `Ctrl-j`, `Enter` | Insert new line | `insert_newline` |
338-
| `Backspace`, `Ctrl-h` | Delete previous char | `delete_char_backward` |
339-
| `Delete`, `Ctrl-d` | Delete next char | `delete_char_forward` |
340-
341-
However, if you really want navigation in insert mode, this is supported. An
342-
example config that gives the ability to use arrow keys while still in insert
343-
mode:
344-
345-
```toml
346-
[keys.insert]
347-
"up" = "move_line_up"
348-
"down" = "move_line_down"
349-
"left" = "move_char_left"
350-
"right" = "move_char_right"
351-
"C-b" = "move_char_left"
352-
"C-f" = "move_char_right"
353-
"A-b" = "move_prev_word_end"
354-
"C-left" = "move_prev_word_end"
355-
"A-f" = "move_next_word_start"
356-
"C-right" = "move_next_word_start"
357-
"A-<" = "goto_file_start"
358-
"A->" = "goto_file_end"
359-
"pageup" = "page_up"
360-
"pagedown" = "page_down"
361-
"home" = "goto_line_start"
362-
"C-a" = "goto_line_start"
363-
"end" = "goto_line_end_newline"
364-
"C-e" = "goto_line_end_newline"
365-
"A-left" = "goto_line_start"
366-
```
328+
| Key | Description | Command |
329+
| ----- | ----------- | ------- |
330+
| `Escape` | Switch to normal mode | `normal_mode` |
331+
| `Ctrl-s` | Commit undo checkpoint | `commit_undo_checkpoint` |
332+
| `Ctrl-x` | Autocomplete | `completion` |
333+
| `Ctrl-r` | Insert a register content | `insert_register` |
334+
| `Ctrl-w`, `Alt-Backspace` | Delete previous word | `delete_word_backward` |
335+
| `Alt-d`, `Alt-Delete` | Delete next word | `delete_word_forward` |
336+
| `Ctrl-u` | Delete to start of line | `kill_to_line_start` |
337+
| `Ctrl-k` | Delete to end of line | `kill_to_line_end` |
338+
| `Ctrl-h`, `Backspace` | Delete previous char | `delete_char_backward` |
339+
| `Ctrl-d`, `Delete` | Delete next char | `delete_char_forward` |
340+
| `Ctrl-j`, `Enter` | Insert new line | `insert_newline` |
341+
342+
These keys are not recommended, but are included for new users less familiar
343+
with modal editors.
344+
345+
| Key | Description | Command |
346+
| ----- | ----------- | ------- |
347+
| `Up` | Move to previous line | `move_line_up` |
348+
| `Down` | Move to next line | `move_line_down` |
349+
| `Left` | Backward a char | `move_char_left` |
350+
| `Right` | Forward a char | `move_char_right` |
351+
| `PageUp` | Move one page up | `page_up` |
352+
| `PageDown` | Move one page down | `page_down` |
353+
| `Home` | Move to line start | `goto_line_start` |
354+
| `End` | Move to line end | `goto_line_end_newline` |
367355

368356
## Select / extend mode
369357

helix-term/src/keymap/default.rs

+17-14
Original file line numberDiff line numberDiff line change
@@ -345,24 +345,27 @@ pub fn default() -> HashMap<Mode, Keymap> {
345345
let insert = keymap!({ "Insert mode"
346346
"esc" => normal_mode,
347347

348-
"backspace" => delete_char_backward,
349-
"C-h" => delete_char_backward,
350-
"del" => delete_char_forward,
351-
"C-d" => delete_char_forward,
352-
"ret" => insert_newline,
353-
"C-j" => insert_newline,
354-
"tab" => insert_tab,
355-
"C-w" => delete_word_backward,
356-
"A-backspace" => delete_word_backward,
357-
"A-d" => delete_word_forward,
358-
"A-del" => delete_word_forward,
359348
"C-s" => commit_undo_checkpoint,
349+
"C-x" => completion,
350+
"C-r" => insert_register,
360351

361-
"C-k" => kill_to_line_end,
352+
"C-w" | "A-backspace" => delete_word_backward,
353+
"A-d" | "A-del" => delete_word_forward,
362354
"C-u" => kill_to_line_start,
355+
"C-k" => kill_to_line_end,
356+
"C-h" | "backspace" => delete_char_backward,
357+
"C-d" | "del" => delete_char_forward,
358+
"C-j" | "ret" => insert_newline,
359+
"tab" => insert_tab,
363360

364-
"C-x" => completion,
365-
"C-r" => insert_register,
361+
"up" => move_line_up,
362+
"down" => move_line_down,
363+
"left" => move_char_left,
364+
"right" => move_char_right,
365+
"pageup" => page_up,
366+
"pagedown" => page_down,
367+
"home" => goto_line_start,
368+
"end" => goto_line_end_newline,
366369
});
367370
hashmap!(
368371
Mode::Normal => Keymap::new(normal),

runtime/tutor

+18
Original file line numberDiff line numberDiff line change
@@ -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.

0 commit comments

Comments
 (0)