[vim/vim] Cannot map Alt+Shift+letter while using Kitty. (Issue #11936)

6 views
Skip to first unread message

Adrian Trunzo

unread,
Feb 2, 2023, 6:46:01 PM2/2/23
to vim/vim, Subscribed

Steps to reproduce

When using Vim in Kitty, I can map Alt+[a-z] (Alt and a lowercase letter) without issues, but I cannot map Alt+[A-Z] (Alt and an uppercase letter).

To reproduce on macOS, make sure you are running Kitty with the macos_option_as_alt setting:

kitty -c NONE -o macos_option_as_alt=both

Verify mapping without Shift works:

  1. Open Vim with no-shift mapping: vim -Nu NONE +'nnoremap <M-b> <Cmd>echomsg "M-b"<CR>'
  2. Press Alt+b
  3. Verify the M-b message appears.

Reproduce mapping with Shift does not work:

  1. Open Vim with shift mapping: vim -Nu NONE +'nnoremap <M-B> <Cmd>echomsg "M-B"<CR>'
  2. Press Alt+Shift+b
  3. Verify that no message appears

In both cases, you can verify that the Kitty Keyboard Protocol is used with :verbose map. For example:

Kitty keyboard protocol: On

n  <M-b>       * <Cmd>echomsg "M-b"<CR>

        Last set from -c argument

v  <BS>          "-d

v  <D-x>         "*d

v  <D-c>         "*y

v  <D-v>         "-d"*P

n  <D-v>         "*P

Press ENTER or type command 

Curiously, in WezTerm, which implements the same keyboard protocol, Vim doesn't recognize a difference between pressing Alt+[a-z] and Alt+Shift+[a-z]. To reproduce this behavior, run WezTerm with the Kitty Keyboard Protocol enabled:

wezterm --config enable_kitty_keyboard=true

If using macOS, use the left alt/option key with WezTerm to avoid the default option key composition.

  1. Open Vim with no-shift mapping: vim -Nu NONE +'nnoremap <M-b> <Cmd>echomsg "M-b"<CR>'
  2. Press Alt+b
  3. Verify the M-b message appears
  4. Close Vim and open it again with the same command
  5. Press Alt+Shift+b and verify the M-b message appears.

Expected behaviour

I expect the <M-B> mapping to work when pressing Alt+Shift+B in Kitty (and WezTerm).

Version of Vim

9.0.1250

Environment

OS: macOS Ventura 13.1
Terminals: Kitty 0.26.5, WezTerm 20221119-145034-49b9839f
$TERM: xterm-kitty, wezterm
Shell: zsh 5.8.1 (x86_64-apple-darwin22.0)

Logs and stack traces

With vim -Nu NONE --log vim.txt in Kitty, I get the following sequence for pressing Alt+b and then Alt+Shift+B. 98;3u and 98;4u match the Kitty Keyboard Protocol expected sequences for Alt without Shift and Alt+Shift.

  2.590488 : raw key input: "�[98;3u"

  2.590570 : SafeState: reset: key typed

  2.590589 : SafeState: Start triggering

  2.590613 : raw terminal output: ""

  2.590625 : looking for messages on channels

  2.590633 : SafeState: back to waiting, triggering SafeStateAgain

  4.072293 : raw key input: "�[98;4u"

  4.072357 : SafeState: reset: ins_typebuf()

  4.072395 : SafeState: Start triggering

  4.072420 : raw terminal output: ""

  4.072431 : looking for messages on channels

  4.072439 : SafeState: back to waiting, triggering SafeStateAgai


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11936@github.com>

Christian Brabandt

unread,
Feb 3, 2023, 7:24:06 AM2/3/23
to vim/vim, Subscribed

Can you try, if mapping <M-S-B> works instead?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11936/1415801668@github.com>

Bram Moolenaar

unread,
Feb 3, 2023, 7:45:18 AM2/3/23
to vim/vim, Subscribed

Try out with patch 9.0.1276 if you can.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11936/1415823017@github.com>

Adrian Trunzo

unread,
Feb 8, 2023, 12:57:26 AM2/8/23
to vim/vim, Subscribed

Patch 9.0.1276 resolves my issue, thanks.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11936/1422055531@github.com>

Adrian Trunzo

unread,
Feb 8, 2023, 12:57:27 AM2/8/23
to vim/vim, Subscribed

Closed #11936 as completed.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/11936/issue_event/8464989091@github.com>

Reply all
Reply to author
Forward
0 new messages