[vim/vim] Vim doesn't recognize raw key codes in mappings (Issue #19182)

1 view
Skip to first unread message

erry

unread,
Jan 15, 2026, 12:54:26 AM (yesterday) Jan 15
to vim/vim, Subscribed
AstroSnail created an issue (vim/vim#19182)

Steps to reproduce

Failing case 1:

  1. Open vim --clean.
  2. :set cpo? and observe that it doesn't contain k. This should mean that Vim translates raw termcodes in mappings into internal keycodes.
  3. :set t_ku? and observe that it is set to ^[O*A.
  4. :map X ^[OA (like how :help cpo-k suggests; use CTRL-V ESC to type ^[)
  5. ia<CR>a<CR>a<CR>a<Esc> (that is, type four lines of a into the buffer, or whatever you wish)
  6. XXX and observe that the cursor goes up.
  7. :set t_ku=
  8. G and observe that the cursor goes back to the bottom.
  9. XXX and observe that a new line is opened above the last line and AXX is typed into it.

Working case:

  1. Follow steps 1 and 2 above.
  2. :set t_ku=^[OA (use CTRL-V ESC to type ^[)
  3. Follow steps 4 through 9 above.
  4. Observe that at step 9 the cursor goes up like in step 6.

Failing case 2:

  1. Follow steps 1 and 2 above.
  2. :set t_ku=^[OA (use CTRL-V ESC to type ^[)
  3. :map X <Esc>OA (that is, < E s c > is typed with those 5 characters exactly)
  4. Follow steps 5 through 9 above.
  5. Observe that at step 9 a new line is opened and AXX is typed.

Failing case 3:

  1. Follow steps 1 and 2 above.
  2. :set t_ku=^[OA (use CTRL-V ESC to type ^[)
  3. :map X ^[OAjk (use CTRL-V ESC to type ^[)
  4. Follow steps 5 through 9 above.
  5. Observe that at step 9 a new line is opened and AjkXX is typed.

I believe failing case 1 is caused by find_term_bykeys not being able to find termcodes with modifier placeholders (like the * in ^[O*A). I believe failing case 3 is caused by replace_termcodes passing the whole (rest of) input into find_term_bykeys, which doesn't permit trailing text for a matching code.

Expected behaviour

Step 9 should move the cursor up in all cases. Vim should behave like :map X ^[OA and :map X <Esc>OA are the same as :map X <Up>, and :map X ^[OAjk is the same as :map X <Up>jk, as long as cpoptions doesn't contain k.

Version of Vim

9.1.1918

Environment

Operating system:

  • system: "x86_64-linux"
  • host os: Linux 6.12.63, NixOS, 26.05 (Yarara), 26.05pre925861.ffbc9f8cbaac
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.31.2+2
  • channels(root): "home-manager, nixos"
  • channels(erry): "home-manager"
  • nixpkgs: /nix/store/c126faazjcllyfyh28hhhgd97dajc9iq-nixos/nixos

Terminal: XTerm(404)
Value of $TERM: xterm-256color
Shell: GNU bash, version 5.3.3(1)-release (x86_64-pc-linux-gnu)

Logs and stack traces


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/19182@github.com>

Reply all
Reply to author
Forward
0 new messages