helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
33.26k stars 2.47k forks source link

"C-S-something" doesn't seem to be a valid remap key #7533

Closed kristian-clausal closed 10 months ago

kristian-clausal commented 1 year ago

In the documentation there's an example of "C-S-esc" being used as an example, but the syntax "C-S-" does not work for letters, like "C-S-k" or "A-S-n". I couldn't get "C-S-esc" to work either, but that's not unexpected on a basic terminal (MATE terminal). "A-N" works, but some combinations like "A-I" and "A-O" don't, which is probably because they're caught somewhere else. Trying to use "A-O" does nothing on the first stroke and then "O" (new line before selected line).

In any case, the documentation for remapping could use some checking.

the-mikedavis commented 1 year ago

For character keys (i.e. not special keys like backspace or escape) we remove the shift modifier and shift the character: https://github.com/helix-editor/helix/blob/57e538d07b15c7ac33a0469f1ca05981704ee5af/helix-term/src/ui/editor.rs#L1495-L1503

So S- is only needed for non-character keys. The documentation lives here if you'd like to create a PR to add a note about this: https://github.com/helix-editor/helix/tree/master/book/src.

About the alt keys, yeah your terminal emulator or operating system is most likely eating those keypresses.

mkon commented 1 year ago

I am having a similar issue with the shift key on macOS

I am trying a config like

[keys.normal]
"C-N" = "extend_search_prev"
"C-n" = "extend_search_next"

[keys.insert]
"C-p" = "paste_after"
"C-P" = "paste_before"

In alacritty even when using capital version it always triggers the lower case binding. In macOS default terminal the capital case does not trigger anything. Is there a way to debug this further?

4164696f73 commented 1 year ago

Linux user here.

I've found similar issue, though without shift key. C-backspace = "delete_word_backward" doesn't do anything, and I've also tried in multiple shells and terminals (well, only two - bash and zsh, alacritty and xfce-terminal), thinking it's a me-problem.

On the other hand, C-del = "delete_word_forward" works fine, doesn't matter what command I use. Mode also does not matter - C-del works normal/insert, while C-backspace does not.

PS: Tmux or not, same issue.

the-mikedavis commented 1 year ago

That's unrelated: C-backspace has the same escape sequence as backspace by default. You'll need to use a terminal that supports the enhanced keyboard protocol https://github.com/helix-editor/helix/wiki/Terminal-Support#enhanced-keyboard-protocol

flinesse commented 10 months ago

I'm encountering a similar problem as well trying to do the following:

[keys.insert]
A-ret = ["open_below"]
A-S-ret = ["open_above"]

Alt-Enter keybind seems to work for me but not the Alt-Shift-Enter one \ \ I'm using wezterm on macOS; it had no trouble receiving the chorded key event:

20:52:09.051  INFO   wezterm_gui::termwindow::keyevent > key_event RawKeyEvent { key: Char('\r'), modifiers: SHIFT | ALT | LEFT_ALT, leds: (empty), phys_code: Some(Return), raw_code: 36, repeat_count: 1, key_is_down: true, handled: Handled(false) }
20:52:09.052  INFO   wezterm_gui::termwindow::keyevent > key_event KeyEvent { key: Char('\r'), modifiers: SHIFT | ALT | LEFT_ALT, leds: (empty), repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Char('\r'), modifiers: SHIFT | ALT | LEFT_ALT, leds: (empty), phys_code: Some(Return), raw_code: 36, repeat_count: 1, key_is_down: true, handled: Handled(false) }) }
20:52:09.052  INFO   wezterm_gui::termwindow::keyevent > Char('\r') SHIFT | ALT | LEFT_ALT -> send to pane Enter SHIFT | ALT | LEFT_ALT
20:52:09.052  INFO   wezterm_term::terminalstate::keyboard > key_down: sending "\u{1b}\r", Enter SHIFT | ALT | LEFT_ALT
20:52:09.140  INFO   wezterm_gui::termwindow::keyevent     > key_event RawKeyEvent { key: Char('\r'), modifiers: SHIFT | ALT | LEFT_ALT, leds: (empty), phys_code: Some(Return), raw_code: 36, repeat_count: 1, key_is_down: false, handled: Handled(false) }