Skip to content

Commit

Permalink
Keep arrow and special keys in insert
Browse files Browse the repository at this point in the history
Advanced users won't need it and is useful for beginners.
Revert part of helix-editor#3671.
  • Loading branch information
pickfire committed Sep 20, 2022
1 parent 5467c65 commit ccf296c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
42 changes: 16 additions & 26 deletions book/src/keymap.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions helix-term/src/keymap/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,17 @@ pub fn default() -> HashMap<Mode, Keymap> {

"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),
Expand Down

0 comments on commit ccf296c

Please sign in to comment.