Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to the Power Users community on Codidact!

Power Users is a Q&A site for questions about the usage of computer software and hardware. We are still a small site and would like to grow, so please consider joining our community. We are looking forward to your questions and answers; they are the building blocks of a repository of knowledge we are building together.

Post History

50%
+0 −0
Q&A Allow extended keys in tmux?

I tested in tmux 3.5a. When tmux is configured as set extended-keys off, there is no support for extended keys. When tmux is configured as set extended-keys on, it expects a program in th...

posted 2d ago by Kamil Maciorowski‭

Answer
#1: Initial revision by user avatar Kamil Maciorowski‭ · 2025-06-11T19:18:16Z (2 days ago)
I tested in tmux 3.5a.

- When tmux is configured as `set extended-keys off`, there is no support for extended keys.

- When tmux is configured as `set extended-keys on`, it expects a program in the pane to actively request support for extended keys by printing the right escape sequence; and it expects the program to possibly withdraw the request by printing another escape sequence (e.g. when the program exits).

  There are two modes of support:

  1. Mode 1 which changes the sequence for only keys which lack an existing well-known  representation. The escape sequence to request mode 1 is `\033[>4;1m` (where `\033` denotes the escape character).
  0. Mode 2 which changes the sequence for all keys. the escape sequence to request mode 2 is `\033[>4;2m`.

  The escape sequence to switch to the standard mode ("withdraw the request") is `\033[>4;0m`.

- When tmux is configured as `set extended-keys always`, switching to the standard mode forces mode 1. A new tmux server will start in mode 1 if `set extended-keys always` is in `.tmux.conf`. (Note that changing the configuration of an already running server to `always` will not automatically switch from the standard mode to mode 1.)

Vim does not print the right escape sequences automatically, this is why it does not work with `extended-keys on`. **Your options:**

- **Put `set extended-keys always` in your `.tmux.conf`.**
- Or use `set extended-keys on` and switch modes manually (e.g. run `printf '\033[>4;1m'` before starting Vim, `printf '\033[>4;0m'` after exiting Vim).
- Or use `set extended-keys on` and find a way to make Vim automatically print the sequence to request mode 1 when it starts, then the sequence to switch to standard mode when it exits.

With the keys you want to use, `set extended-keys always` should be relatively safe; programs that don't understand extended keys may misbehave when you press Ctrl+Enter or Shift+Enter, so just don't press these when working with such programs.

Notes:

- If you ever want to play with mode 2, keep in mind it encodes Ctrl+C, Ctrl+Z, Ctrl+L and such in a way the line discipline and shells don't understand. E.g. you will be unable to send SIGINT by hitting Ctrl+C or clear the terminal by hitting Ctrl+L.

- Tmux can be configured as `set extended-keys-format xterm` or `set extended-keys-format csi-u`. The sequences you told your alacritty to use are in the csi-u format. Tmux understands them regardless of the setting (when it reads them from the tty of the tmux client, ultimately from alacritty), but it converts them according to the setting (when it sends them via the tty of the pane, ultimately to Vim or whatever); so don't be surprised you will observe different sequences upon Ctrl+V Ctrl+Enter in tmux if the setting is `xterm`. Vim shall understand both formats, but in general there may be programs that work well with one format and not with the other.