如何在tmux-vi复制模式下快速滚动时保留上下文



我想知道tmux-vi副本绑定的可能选项是什么。我的.tmux.conf中有以下内容:

bind -t vi-copy e      start-of-line
bind -t vi-copy r      end-of-line
bind -t vi-copy v      begin-selection
bind -t vi-copy V      rectangle-toggle
bind -t vi-copy K      page-up
bind -t vi-copy J      page-down
bind -t vi-copy h      cursor-left  
bind -t vi-copy j      cursor-down
bind -t vi-copy k      cursor-up
bind -t vi-copy l      cursor-right
bind -t vi-copy C-f    cancel

Q1:我在配置文件中已经有一段时间了,不知道最后一列中的选项来自哪里。谷歌搜索只向我显示了其他论坛上有这样的代码片段。我找不到关于这些关键词的文档。有什么想法吗?不,不是手册页:)

Q2:如果可能的话,我想将K更改为(尝试过的和失败的)半页向上,甚至更改为类似"向上5行"的内容,以保留上下文。

尝试但失败:

1) bind -t vi-copy K half-page-up
2) bind -t vi-copy K M-Up
3) bind -t vi-copy K C-u      // already configured half page-up

Thx!

您可以使用tmux list-keys -t vi-copy查看在vi复制模式下映射的所有函数的列表。如果你想查看所有可能的命令,你可以查看源代码,特别是模式键.c。我不认为有任何文档列出了所有命令。

您正在寻找的映射是:

bind-key -t vi-copy 'K' halfpage-up
bind-key -t vi-copy 'J' halfpage-down

不幸的是,这个部分在tmux中没有很好地记录。

这是从源代码中撕下的2.2版"复制模式"命令的完整列表

append-selection
back-to-indentation
begin-selection
bottom-line
cancel
clear-selection
copy-end-of-line
copy-line
copy-pipe
copy-selection
cursor-down
cursor-left
cursor-right
cursor-up
end-of-line
goto-line
halfpage-down
halfpage-up
history-bottom
history-top
jump-again
jump-backward
jump-forward
jump-reverse
jump-to-backward
jump-to-forward
middle-line
next-space
next-space-end
next-word
next-word-end
other-end
page-down
page-up
previous-space
previous-word
rectangle-toggle
scroll-down
scroll-up
search-again
search-backward
search-forward
search-reverse
select-line
start-named-buffer
start-number-prefix
start-of-line
top-line

所有这些命令都适用于vi复制和emacs复制模式,但行为可能会有所不同,从而与vi或emacs保持一致。

tmux处于"模式"时存在一些缺点:

  • "模式"命令没有合理的命令列表或选项卡完成
  • 无法在"模式"中组合命令:您只能将一个操作绑定到一个按键,并且操作集是有限的

还有一个补丁可以解决这些问题:http://ershov.github.io/tmux/

它为tmux添加了全面的脚本支持。

使用它,您可以列出所有可用的命令:

info commands ::tmux::*

列出所有"模式"命令:

info commands ::tmux::mode::*

列出所有"复制模式"命令:

info commands ::tmux::mode::copy::*

在复制模式下绑定多个操作:

bind-key -t vi-copy K tcl { scroll-up ; scroll-up }

最新更新