helix: Ctrl + [ doesn't function as Escape in helix 23.03

I think this is because of the new enhanced keyboard protocol enabled in 23.03. Is there a way to disable it? Although I can remap Ctrl+[ to mode change command, escape has more functions than only mode change. For example, when you enter : to type command, you can’t return back to normal mode using Ctrl+[. And there is no way to remap a key combination to a specific keycode in helix, which is available in vim.

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 18
  • Comments: 21 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Ctrl + [ is the de facto standard esc alternative on macOS, and I don’t think the usage is niche, because Ctrl + [ is especially useful when your keyboard does not have an esc key (which is true for many Mac/iPad users). I’m really looking forward to the upcoming esc remapping feature.

but this workaround can’t substitute all the esc usage with ‘Ctrl-[’, so a feature of keycode remapping should be the best solution.

I also don’t think that using ctrl+[ as esc is a niche use-case, on keyboards with us-layout it is more comfortable to reach (both pinkies) than the actual esc.

For what it’s worth you can run hx inside tmux for the moment as a workaround.

My C-[ muscle memory is so strong that I also do it at prompts and in pickers, which are not currently re-mappable in Helix (that I can find, at least). Would be nice to have it mapped there too.

Yes I agree, I think all of this talk of C-[ being an accident is a little dismissive. Perhaps it was an ‘accident’ once but its usage is certainly not niche (as this issue proves). The reality is that many people expect and rely on this behaviour. This just hit me today as Alacritty 0.13.0 now implements the kitty keyboard protocol.

Came here as someone who has been evangelizing mapping CAPS LOCK to CTRL and then using ctrl-[ in vim for over 20 years now. Specifically as someone who has RSI issues and is able to use caps_lock-[ with two very subtle finger movements vs. any alternative. If it was a mere accident that that worked, it’s an accident that was true for every combination of vi/vim/nvim/etc. in every terminal emulator and every operating system I’ve ever used.

To advocate for Ctrl + [ users.

They are in their right to notice, this is a very old behavior in VT100 terminal that Ctrl+ [ does produce the escape sequence.

To verify that, we may simply use cat:

cat We press Escape That does print ^[ Now we press Ctrl + [ That does also print ^[

Further documentations can be found with keywords: control-escape sequence VT100

I do personally, as a non-Qwerty keyboard user, have to use the key combo Ctrl + AltGr + 4 to output Ctrl + [.

However I do warmly recommend that Helix supports Ctrl + [ as the escape sequence due to legacy reasons.

Hi, just came here to say hat I love helix, and wanted to voice my support that mapping control to caps lock and using C-[ is not a niche use case and should please have first class support. Since I am just some guy on the internet, I’ll try to supplement my argument with some appeals to authority in hopes that this rhetorical flourish will convince people 😃

  • In his book Practical Vim, p.30 author Drew Neil recommends mapping caps lock to ctrl and using C-[ as escape. Quote: “The C-[ mapping is synonymous with Esc , and it’s easier to type when the Ctrl key is within easy reach.”
  • In his talk Stop Writing Deap Programs around the 18:00 minute mark, Jack Rusher says he still maps caps lock to control because it makes his life easier on unix machines (and gives an interesting historical reason for that 😃 )

I can also try and hop on to help with the implementation if this is a resource issue.

These two other control character mappings, backspace ctrl-h and line feed ctrl-j, are still supported after the enhanced keyboard protocol change, so I don’t think it is a stretch to keep supporting ctrl-[ as escape by default.

There is a couple of settings in ~/.tmux.conf that affects the behavior of the escape sequence, and may help with this issue.

In particular the following:

set -sg escape-time 0


In Helix, found the following mapping to be particularly efficient: Ctrl + space

[keys.insert]                                                             
C-space = "normal_mode"    

[keys.normal]
C-space = "insert_mode" 

[keys.select]
C-space = "normal_mode"     

In case it helps anyone… until Helix supports this, using keyd to map C-[ to escape seems to work.

[control]
[ = esc

If tmux doesn’t support the disambiguation of ctrl-[ and esc, then shouldn’t ctrl-[ work as esc in helix? or am I misunderstanding something?

@sdemura, almost 😃 what you want is:

[keys.insert]
  "C-[" = "normal_mode"