tmux tab 与 ctr i 快捷键冲突

警告
本文最后更新于 2023-05-28,文中内容可能已过时。

最近在整合 tmux-vim 的开发环境,准备把之前的 prefixctrl-k 更改为 ctrl-i,结果发现无法完成命令行的自动补全功能。在网上查了一下,原来是因为系统把 ctrl-iTAB 键都当做一个操作指令了,从而导致按下 TAB 的时候,实际上是执行 ctrl-i,如果多次敲击,则会产生两条指令:ctr-i ctri-i,这个恰好了显示 tmuxsidebar 功能,反而不是完成自动补全了。

具体的可以参考这个 StackOverflow 的回答,Tab issues with Vim while running Tmux:

I haven’t really configured anything in tmux besides remapping C-b to C-i.

set -g prefix C-i unbind C-b bind C-i send-prefix

While Tab and the Control-i are usually distinguished in GUI environment, they generate the same character in tty-based environments like terminal emulators. That character is U+0009, which is the Tab control character. It is represented as the single byte 0x09 in ASCII, UTF-8 and many other encodings. All of the “C0 control codes” (ASCII 0-31) have keyboard equivalents that combine the Control key with another key (mostly letters, but also some symbols). The Tab control character is generated by Control-i.

You can verify that (at least) tmux considers C-i and Tab to be the same by looking at the output of tmux show-options -g | grep prefix. You will see it has set your prefix to the key named Tab, even though you specified it as C-i in your configuration. You can also notice the same canonicalization in the output of tmux list-keys | grep prefix.

You may want to pick a different prefix if you do not want to type Tab twice when you want to send one to programs running inside tmux.

相关内容

william 支付宝支付宝
william 微信微信
0%