1

I have a relatively fresh installation of Arch with Hyprland. When using Vim in Kitty, numpad enter inserts the following symbol: instead inserting a newline/executing the typed command. (It doesn't render on my system, but maybe it does on others?)

It does this in both Insert mode and Command mode.

Initially I suspected it due to some strange bug in Kitty, but this test:

Press any keys - Ctrl+D will terminate this program
UNIX        send_text
^M        \r
^M        \r
^M        \r
^M        \r

proves that both enters do the exact same thing in the shell. So it must be a problem in Vim somehow?

What could cause this and how can I fix it?

I am using Vim 9.1.532 if that matters. I'm also using a vimrc that I've been using for years on dozens of computers.

9
  • 1
    Can you try to use :echo getchar() then press both Enter keys and see what they return? The one that works should return 13, but I suspect the one from the keypad might return something different, potentially longer
    – filbranden
    Commented Jul 24 at 21:02
  • 1
    @fibranden: ENTER returns 13, KP_ENTER returns 57414. Both term commands return xterm-kitty. The remapping works, but ideally I would solve the root cause instead of working around it by remapping the key in the vimrc. (It also makes the vimrc less generic for me)
    – Opifex
    Commented Jul 24 at 21:06
  • 1
    Does this fix it for you? :let &t_KA = nr2char(57414) Yes it's a workaround, but you can still make your vimrc only apply that under Kitty (by looking at the term setting)
    – filbranden
    Commented Jul 24 at 21:12
  • 1
    @filbranden yes, that fixes it for me. I will use it for now. Thanks! Still, figuring out the root cause would be worthy of an Accepted Answer :)
    – Opifex
    Commented Jul 24 at 21:20
  • 1
    Yes definitely! I just wanted to make sure this was going to work for you before posting an answer. Thanks for your quick replies!
    – filbranden
    Commented Jul 24 at 21:24

1 Answer 1

1

It is possible that Vim doesn't fully support Kitty and the xterm-kitty terminal definitions (for instance, there are Neovim issues that mention improving Kitty terminal support.)

As a workaround, you can use the settings under :set termcap to override specific keys, such as <kEnter> also known as t_KA in your setup.

In order to add a workaround to your .vimrc to set t_KA appropriately when Vim is running on your Kitty terminal, you can use the following:

if &term == 'xterm-kitty'
  let &t_KA = nr2char(57414)
endif
1
  • 1
    It's probably rather an issue with an oudated terminfo database. Commented Jul 25 at 6:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.