0

I am using Arch Linux with Sway and a pseudoterminal which is currently termite.

Typically inside of that I am running tmux and then vim inside of tmux.

My problem is that I cannot get ctrl+1 or alt+1 key bindings to work or ctrl+shift+1 etc.

I tried creating a binding in tmux like this (in the tmux conf):

bind -n C-1 send-keys -X "xzy whatever"

but it did not work. How can I get these kinds of bindings to work?

I notice that I can get ctrl bindings to work if I define them in the sway config, but I do not want to try to make vim commands defined in my sway config.

1 Answer 1

2

Graphical applications receive keystrokes as key combinations (such as ctrl1 is sent as 1 with the ctrl modifier key held) but applications running in a terminal instead receive single byte codes (ascii), where ctrl can only be combined with letters and a few symbols (@[\]^_) (see man ascii).

The only way to be able to bind to those key combinations would be to use a graphical version of the application (e.g., graphical emacs, maybe graphical vim) or have the graphical terminal translate it via a macro if it supported that.

2
  • But see also: invisible-island.net/xterm/xterm.faq.html#xterm_modother : terminal can be told to send C-1 as a special sequence. And possibly vim support it, but OP as also a tmux.... things may be more complex, but possibly solvable Commented Oct 31, 2024 at 15:36
  • Yes, some of the ctrl codes overlap with special keys and are indistinguishable to terminal apps, and some special keys emit multiple characters. I considered covering that but thought that was a bit out of scope for the question. I don't think tmux really changes any of this since it's just another terminal app and passes through most stuff. Commented Nov 1, 2024 at 11:24

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.