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

Can't map commands to “C-ret" "S-ret" "C-m" #6137

Closed
pzzxqj opened this issue Feb 28, 2023 · 9 comments
Closed

Can't map commands to “C-ret" "S-ret" "C-m" #6137

pzzxqj opened this issue Feb 28, 2023 · 9 comments
Labels
C-bug Category: This is a bug

Comments

@pzzxqj
Copy link

pzzxqj commented Feb 28, 2023

Summary

I try to some key remapping below, but not working.

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

Reproduction Steps

  1. :config-open
  2. write config
  3. :config-reload

Helix log

No response

Platform

Linux

Terminal Emulator

konsole

Helix Version

helix 22.12 (8dab8a0)

@pzzxqj pzzxqj added the C-bug Category: This is a bug label Feb 28, 2023
@the-mikedavis
Copy link
Member

The escape sequences the terminal uses to describe these events are ambiguous with the default way that key events are reported. #4939 supports accepting events from an enhanced keyboard protocol but this only works if your terminal supports the enhanced keyboard protocol. I don't think it's implemented in Konsole (https://sw.kovidgoyal.net/kitty/keyboard-protocol/#comprehensive-keyboard-handling-in-terminals) but you can check by running in verbose mode with hx -vv. The log file should have a line that says "The enhanced keyboard protocol is supported on this terminal" or "The enhanced keyboard protocol is not supported on this terminal".

If it isn't supported for Konsole, you will need to use a terminal emulator that supports the protocol to be able to use these bindings.

@pzzxqj
Copy link
Author

pzzxqj commented Feb 28, 2023

Thank your suggestion, I'm trying a new terminal, kitty. Now it's OK.

I see that Ctrl+m act like Enter in insert mode. Key mapping for Ctrl+m also not working. Is it special key sequence?
I don't exactly get it.

@the-mikedavis
Copy link
Member

There isn't a special case for C-m in the codebase as far as I know. I would expect C-m to act like enter if you are using the keybinding in the issue description though:

[keys.insert]
C-m = "open_below"

With that binding, C-m in insert mode should act like o does in normal mode.

You can also try a rebinding like

[keys.normal]
C-m = "toggle_comments"

which should make C-m act like C-c in normal mode - it will toggle comments for the currently selected lines

@pzzxqj
Copy link
Author

pzzxqj commented Feb 28, 2023

It is not working as your description. C-m always equates to enter.

@pzzxqj
Copy link
Author

pzzxqj commented Feb 28, 2023

append reply, it doesn't work in konsole.

@the-mikedavis
Copy link
Member

Oh I see, yeah that's expected behavior in Konsole or any terminal emulator that doesn't support the keyboard enhancement protocol. The escape sequence for C-m is the same as Enter. There are a bunch of other ambiguous key combinations like C-backspace being the same as C-h.

@pzzxqj
Copy link
Author

pzzxqj commented Feb 28, 2023

It's mean that the action of C-m is decided by terminal?

@the-mikedavis
Copy link
Member

For all the terminal emulators that I know of, C-m sends the same escape sequence as Enter. You can tell C-m and Enter apart if the terminal and the app (Helix in this case) enable and use the enhanced keyboard protocol but otherwise they look the same.

@pzzxqj
Copy link
Author

pzzxqj commented Mar 1, 2023

It is very useful for me, thank you

@pzzxqj pzzxqj closed this as completed Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

2 participants