helix: Alt(Opt)+_ keymaps do Not work on macOS
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 (d4e45fd4)
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 12
- Comments: 16 (7 by maintainers)
On further reading this what Helix is doing is the standard for most CLI programs. Mac
Optis different thanAlt(with behavior like accenting characters). And terminal emulators that support macOS (almost?) invariably have a way to map the key code, typically to “Esc+”.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
Optin 5 common terminal emulators on macOS.Opt_key ~~~> ≃Alt_key
iTerm2 (3.4.15) [web reference] : remapping is done via Preferences > Profiles > Keys > General > [radio button interface]
Kitty (0.25.1) [web reference] : remapping is done via Preferences > search for
max_os_opt_as_alt> uncomment and set toleft,right, orbothWezTerm (20220408-101518-b908e2dd) [unneeded web reference] : Already mapped by default. 👍
Alacritty (0.10.1) [web ≈reference]
Opt+`in Helix: running the command once did nothing and running it a second time performed the desired action. This seemed to occur regardless of time between key-combo presses, as long as there were no intervening presses. If anyone has info to add on configuring Alacrity keymapping behavior or documentation on the above behavior: please do share. 😃“Terminal” macOS_default (2.12.7) [web reference] : remapping is done via Preferences > Profiles > click button at bottom labelled “Use Option as Meta key”
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:
https://github.com/alacritty/alacritty/commit/d9ba129e9e722a551cc0cc4c1899c97593ca26b4
This allows the Option key to behave as Alt. An example
alacritty.ymlwill look like:Not released yet, but I’d imagine this will be out in the next version. These are the related issues leading to the change:
https://github.com/alacritty/alacritty/issues/62 https://github.com/rust-windowing/winit/pull/2576
+1 with this issue, and using Warp as the terminal app, but can be fixed by setting the preferences as follows:
My 2 cents, when using
Use Option as Meta keyin Terminal it solves the problem… but you cannot useoptionas compose key anymore, and thus typing accents for example.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
alt+<something>:(this is for the EurKEY layout)
wezterm 20230320-124340-559cb7b0 does not appear to map this by default. I had to add this to my config:
See: https://wezfurlong.org/wezterm/config/keyboard-concepts.html#macos-left-and-right-option-key https://github.com/wez/wezterm/issues/216
The characters that @ethanmsl provided are the same ones that show up when I run
showkey -aon Linux via SSH in iTerm2.It’s also what you get by default when typing in any text input on Mac OS. Mac OS just seems to translate the
Alt+<key>presses into other unicode code points.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 , . /
showkeyisn’t available on mac (in zsh, bash, or fish).Using the 3rd option above:
(Alt := Option)
˙-4 / 0x4∆-38 / 0x26˚-40 / 0x28¬-37 / 0x25…-41 / 0x294 / 0x438 / 0x2640 / 0x2837 / 0x2541 / 0x29If there’s a more useful way to acquire and relay these just lmk.