Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep arrow and special keys in insert #3915

Merged
merged 5 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
pickfire marked this conversation as resolved.
Show resolved Hide resolved

These keys are not recommended, it is for those who do not read documentations.
Copy link
Contributor Author

@pickfire pickfire Sep 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if we even need this line given that most likely they won't even read documentation. Not sure if we have to say there are some bugs there that are not fixed given the low usage.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should say "These keys are not recommended, but are included for new users less familiar with modal editors"

Copy link
Contributor

@aral aral Sep 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Genuinely happy to see this. Again, not for me (I’ve already added the mappings back in my config and am running from source) but in terms of the culture of the project and what it says for how new folks are welcomed. This might seem like a tiny thing but it does make a world of difference in terms of how someone feels when they’re not familiar with a new tool.

This is saying “hey, we recognise this is how nearly every other editor out there works and that you have muscle memory you’re bringing with you… that’s ok. This tool is designed with a different workflow in mind – which you’ll learn in time unless we lose you in the first 30 seconds – but we will cater for your needs to make your introduction more seamless.”

Happy to see Helix embracing a more open/welcoming approach than “our way or the highway.” I truly believe that (whether by accident or not), this is one of those things that has brought a lot of people who would otherwise not have used a modal editor to Helix.

💕


| 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` |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Page down/up will have to be removed too if we're going with only arrow keys and home/end.

Copy link
Contributor Author

@pickfire pickfire Sep 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also support page down/up since it is one special key keyboard have that is similar to arrow keys and home/end, and it works without pressing C-? If anything, I think page up/down is more useful than home/end.

I will be keeping this for now unless other team members disagree here.

| `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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's right to restore C- mappings but not the A- mappings.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though that seems to be the nvim default so maybe it's ok

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But kakoune only supports arrow keys (no ctrl or alt mappings)

Copy link
Contributor Author

@pickfire pickfire Sep 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only added back C- keys because like other (non-modal) editors and browsers, C- is used to move between word, not A- so the familiarity comes from there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove C-left, C-right and pageup, pagedown to match kakoune.

"pageup" => page_up,
"pagedown" => page_down,
"home" => goto_line_start,
"end" => goto_line_end_newline,
});
hashmap!(
Mode::Normal => Keymap::new(normal),
Expand Down