Files
neovim/runtime/doc
Mantas Mikulėnas 574ea6a191 fix(keycodes): recognize <Find>, <Select> #28431
PuTTY sets TERM=xterm, but sends ESC[1~ and ESC[4~ for Home/End keys,
which does not match what the 'xterm' terminfo has for khome/kend, so
libtermkeys instead reports them as the original DEC VT220 names.

The VT220 came with a DEC LK201 keyboard which had the following keys in
the area above arrow keys (where PCs now have Ins/Del/Home/End/etc):

  ┌────────┬────────┬────────┐
  │ Find   │ Insert │ Re-    │
  │        │ Here   │ move   │
  ├────────┼────────┼────────┤
  │ Select │ Prev   │ Next   │
  │        │ Screen │ Screen │
  └────────┴────────┴────────┘

These would send ESC[x~ sequences in the expected order:

  ┌────────┬────────┬────────┐
  │ ESC[1~ │ ESC[2~ │ ESC[3~ │
  ├────────┼────────┼────────┤
  │ ESC[4~ │ ESC[5~ │ ESC[6~ │
  └────────┴────────┴────────┘

Modern terminals continue to use the same sequences for Ins/Del as well
as PageUp/PageDn. But the VT220 keyboard apparently had no Home/End, and
PuTTY apparently chose to re-purpose the Find/Select key sequences for
Home/End (even though it claims to emulate Xterm and this doesn't match
what actual Xterm does).

So when Home/End are used in Neovim through PuTTY with TERM=xterm (the
default setting), libtermkey finds no match for the received sequences
in the terminfo database and defaults to reporting them as <Find> and
<Select> respectively.

PuTTY is not unique here -- tmux *also* sends ESC[1~ and ESC[4~ after
its internal translation -- but the difference is that 'tmux' terminfo
correctly maps them to Home/End so Neovim recognizes them as such, while
PuTTY defaults to using 'xterm' which uses a different mapping.

This initial patch only allows Neovim to recognize <Find> and <Select>
key codes as themselves, so that the user could manually map them e.g.
using ":imap <Find> <Home>".

Alternatives:

  - Using TERM=putty(-256color) would of course be the most correct
    solution, but in practice it leads to other minor issues, e.g. the
    need to have different PuTTY config profiles for older or non-Linux
    systems that lack that terminfo, or tmux's insistence on rendering
    italics as reverse.

  - Using Neovim through tmux avoids the problem (as tmux recognizes
    ESC[1~ on input), but is something that needs to be manually run
    every time.

The keycodes.h constants are slightly misnamed because K_SELECT was
already taken for a different purpose.
2025-02-20 05:26:46 -08:00
..
2025-02-17 10:33:20 +08:00
2023-07-25 05:07:13 -07:00
2025-01-01 12:29:51 -08:00
2024-10-23 14:13:42 +02:00
2024-05-15 23:19:26 +02:00
2025-02-17 10:33:20 +08:00
2024-10-23 14:13:42 +02:00
2023-06-25 17:14:28 +02:00
2023-10-29 16:02:32 +08:00
2025-02-10 18:56:11 +01:00
2025-01-09 09:26:45 -08:00
2023-05-13 21:33:22 +02:00
2025-02-17 10:33:20 +08:00
2025-02-19 10:09:09 -08:00
2025-01-11 10:34:12 +01:00
2025-02-19 10:09:09 -08:00
2024-03-12 13:51:53 +08:00
2025-02-17 10:33:20 +08:00
2022-10-14 08:01:13 -07:00
2024-11-21 06:50:30 +08:00
2023-11-06 19:03:08 +08:00
2024-01-18 00:14:48 -08:00
2024-04-30 04:30:21 -07:00
2025-01-01 12:29:51 -08:00
2023-01-01 15:05:13 +01:00
2023-06-19 08:40:33 -07:00
2025-01-30 13:46:06 +01:00
2025-02-15 14:55:25 +01:00
2023-08-10 17:28:02 +08:00
2025-01-03 08:29:36 -08:00
2024-04-23 08:20:36 +08:00
2024-05-11 18:14:03 +08:00
2023-04-23 15:22:55 +02:00
2023-01-03 10:07:43 +00:00
2023-06-25 17:14:28 +02:00
2023-06-19 08:40:33 -07:00
2023-06-25 17:14:28 +02:00
2023-06-25 17:14:28 +02:00
2023-06-25 17:14:28 +02:00
2023-06-25 17:14:28 +02:00
2024-04-30 05:54:03 +08:00
2023-06-26 11:29:12 +02:00
2023-07-25 05:07:13 -07:00
2023-06-19 08:40:33 -07:00
2023-06-25 17:14:28 +02:00
2025-02-17 10:33:20 +08:00