-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Alt(Opt)+_ keymaps do Not work on macOS #2280
Comments
I'm not sure this can be handled within Helix since we're only getting what the terminal sends us for keycodes. If you start up $ showkey -a
Press any keys - Ctrl-D will terminate this program
^[j 27 0033 0x1b # Alt-j
106 0152 0x6a
^[k 27 0033 0x1b # Alt-k
107 0153 0x6b
^[h 27 0033 0x1b # Alt-h
104 0150 0x68
^[l 27 0033 0x1b # Alt-l
108 0154 0x6c
^J 10 0012 0x0a # Ctrl-j
^K 11 0013 0x0b # Ctrl-k
^H 8 0010 0x08 # Ctrl-h
^L 12 0014 0x0c # Ctrl-l
^C 3 0003 0x03 # Ctrl-c
^D 4 0004 0x04 # Ctrl-d |
I'm using linux but I had a similar problem because I configured my left alt key to be used as the level-3 key because I often use level-3 characters on my keyboard layout. I solved the problem by just mapping the characters that my keyboard layout produces for "ó" = "repeat_last_motion"
"ij" = "expand_selection"
"ú" = "shrink_selection"
"ù" = "select_prev_sibling"
"ø" = "select_next_sibling" (this is for the EurKEY layout) |
Using the 3rd option above: (Alt := Option)
If there's a more useful way to acquire and relay these just lmk. |
Actually the best tool to use would be crossterm's event-read example: https://github.com/crossterm-rs/crossterm/blob/09ffd70c30cd28ee06ef6952e40ec5b2b4eaa57f/examples/event-read.rs That should output the KeyEvents crossterm reads which is what helix is reading. |
The characters that @ethanmsl provided are the same ones that show up when I run It's also what you get by default when typing in any text input on Mac OS. Mac OS just seems to translate the Here's the whole keyboard: ` 1 2 3 4 5 6 7 8 9 0 - = DELETE
TAB q w e r t y u i o p [ ] \
a s d f g h j k l ; ' ENTER
z x c v b n m , . /
|
So for all the [keys.normal]
# Mac Alt-.
"≥" = "repeat_last_motion"
# Mac Alt-` (no way to capture this; Alt-` is the same as `)
# "???" = "switch_to_uppercase"
# Mac Alt-u / Alt-U (no way to capture this; Alt-u is the same as Alt-U)
# "¨" = "earlier"
# "¨" = "later"
# Mac Alt-d
"∂" = "delete_selection_noyank"
# Mac Alt-c
"ç" = "change_selection_noyank"
# Mac Alt-|
"«" = "shell_pipe_to"
# Mac Alt-!
"⁄" = "shell_append_output"
# Mac Alt-s
"" = "split_selection_on_newline"
# Mac Alt-;
"…" = "flip_selections"
# Mac Alt-:
"Ú" = "ensure_selections_forward"
# Mac Alt-,
"≤" = "remove_primary_selection"
# Mac Alt-C
"Ç" = "copy_selection_on_prev_line"
# Mac Alt-(
"·" = "rotate_selection_contents_backward"
# Mac Alt-)
"‚" = "rotate_selection_contents_forward"
# Mac Alt-x
"≈" = "shrink_to_line_bounds"
# Mac Alt-K
"" = "remove_selections"
# Mac Alt-o
"ø" = "expand_selection"
# Mac Alt-i
"ˆ" = "shrink_selection"
# Mac Alt-p
"π" = "select_prev_sibling"
# Mac Alt-n
"˜" = "select_next_sibling"
[keys.insert]
# Mac Alt-d
"∂" = "delete_word_forward"
# Mac Alt-b
"∫" = "move_prev_word_end"
# Mac Alt-f
"ƒ" = "move_next_word_start"
# Mac Alt->
"˘" = "goto_file_end"
# Mac Alt-<
"¯" = "goto_file_start" EDIT: Hmm... If I use that config (just the
|
On further reading this what Helix is doing is the standard for most CLI programs. I don't know what the practicality would be for Helix to work with both the default and mapped keycodes. But, minus giving explicit optioning support in program, naively the best path would be to retain current behavior, but (much like documentation reccomends a terminal emulator to get 24-bit colors) note that remapping the Opt_key is commonly done in mac terminal environments to access Alt-key short-cuts. Given that Helix is especially appealing to terminal newcomers [raises hand] -- that bit of documentation will probably help some users. For (hopefully) helpful reference here is how you remap Opt_key ~~~> ≃Alt_key
|
For Alacritty, the main viable option I've seen is doing a bunch of manual mappings, see alacritty/alacritty#62 |
My 2 cents, when using |
It would be awesome to see this linked in the documentation somewhere so that newcomers can quickly move past this issue. |
For Alacritty, I think this is relevant. A six year old issue in Alacritty has just been resolved with an upstream change to winit: This allows the Option key to behave as Alt. An example window:
# Make `Option` key behave as `Alt` (macOS only):
# - OnlyLeft
# - OnlyRight
# - Both
# - None (default)
option_as_alt: OnlyLeft Not released yet, but I'd imagine this will be out in the next version. These are the related issues leading to the change: |
wezterm 20230320-124340-559cb7b0 does not appear to map this by default.
See: |
@rcorre according to change log
Yielding one that defaults to standard alt (left) and one that does mac option (right) by default. |
I have control mapped to option, and I'm pressing left control. I guess maybe that sends right-alt somehow? |
see also #2469 for some additional discussion |
Summary
None of the Alt+_ (opt+_) keys work on Mac.
Combining experiences (from Matrix chat and testing) neither on Intel nor M1 macs. And neither OSX_11 nor OSX_12. And in neither in default_OSX_terminal nor iTerm2.
iTerm2 allows remapping of Alt/Opt to send an escape code instead. Doing this seems to fix it here. (process outlined here:: https://www.clairecodes.com/blog/2018-10-15-making-the-alt-key-work-in-iterm2/). Though I'm not sure if it causes any other issues.
Note: Alt/Opt does not work by default in iTerm2, but it DOES work by default in the default_osX_terminal -- however the Alt/Opt+_ does not work in Helix in EITHER.
Reproduction Steps
I tried this:
Any of the Alt+_ key sequences are sufficient for testing.
Alt+` is a simple one, as it sends a selection to uppercase.
Alt+. (repeat last motion) is another simple one.
I expected this to happen:
The listed commands to work.
Instead, this happened:
Standard behavior or nothing. (in cases where a combining mark would be produced (e.g. Alt+` or Alt+u, which create ` or ¨, respectively the highlighted combining mark is produced even though Helix is in Normal_Mode...)
Helix log
2022-04-25T06:08:09.677 helix_view::editor [ERROR] Failed to initialize the LSP for
source.julia
{ cannot find binary path }2022-04-25T07:45:54.383 helix_view::editor [ERROR] Failed to initialize the LSP for
source.toml
{ LSP not defined }2022-04-25T21:42:53.303 helix_view::theme [WARN] Theme: invalid style attribute: modifier
2022-04-25T21:43:18.683 helix_view::theme [WARN] Theme: malformed hexcode: fg
2022-04-25T21:43:18.683 helix_view::theme [WARN] Theme: malformed hexcode: form
2022-04-25T21:43:54.696 helix_view::theme [WARN] Theme: malformed hexcode: light-white
2022-04-25T21:44:44.544 helix_view::editor [ERROR] Failed to initialize the LSP for
source.python
{ cannot find binary path }2022-04-25T21:45:15.281 helix_view::theme [WARN] Theme: malformed hexcode: light-white
2022-04-25T21:46:12.776 helix_view::theme [WARN] Theme: malformed hexcode: foreground
2022-04-25T21:46:12.777 helix_view::theme [WARN] Theme: invalid style attribute: Modifiers
2022-04-25T21:46:12.777 helix_view::theme [WARN] Theme: malformed hexcode: grey3
2022-04-25T21:46:12.777 helix_view::theme [WARN] Theme: malformed hexcode: pink
2022-04-25T21:46:45.319 helix_view::theme [WARN] Theme: invalid style attribute: modifier
2022-04-25T21:47:35.998 helix_view::theme [WARN] Theme: malformed hexcode: light-white
2022-04-25T21:47:48.178 helix_view::theme [WARN] Theme: malformed hexcode: form
2022-04-25T21:47:48.178 helix_view::theme [WARN] Theme: malformed hexcode: fg
2022-04-25T21:48:26.578 helix_view::theme [WARN] Theme: malformed hexcode: light-white
2022-04-25T23:41:49.234 helix_view::editor [ERROR] Failed to initialize the LSP for
source.toml
{ LSP not defined }Platform
macOS
Terminal Emulator
default_Version 2.11 (440) && iTerm2_Build_3.4.15
Helix Version
helix 22.03 (d4e45fd)
The text was updated successfully, but these errors were encountered: