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

时间:2014-08-28 13:44:08

标签: tmux

我想知道tmux vi-copy绑定的可能选项是什么。我的.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 :我已经在配置文件中使用了一段时间,并且不知道最后一列中的选项来自哪里。谷歌搜索只向我展示了其他有这样代码片段的论坛。我找不到关于这些关键字的文档。有任何想法吗?不,不是manpage:)

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!

2 个答案:

答案 0 :(得分:2)

您可以使用tmux list-keys -t vi-copy查看以vi-copy模式映射的所有功能的列表。如果您希望查看所有可能的命令,可以查看源代码,特别是mode-key.c。我认为没有任何文档可以列出所有文档。

您正在寻找的映射是:

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

答案 1 :(得分:0)

不幸的是,这部分在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-copy和emacs-copy模式,但行为可能会有所不同,使其与vi或emacs保持一致。

当tmux处于'模式'时有一些缺点:

  • “模式”命令没有合理的命令列表或制表符完成
  • 无法在'mode'中组合命令:您只能将一个动作绑定到一个按键,并且操作集是有限的。

还有一个解决这些问题的补丁: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 }