gospes
gospes

Reputation: 3947

How can I preserve context while scrolling fast in tmux vi-copy mode?

I was wondering what the possible options are for tmux vi-copy bindings. I have the following in my .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: I've had this in my config file for a while and have no idea where the options in the last column come from. A google search only showed me other forums that have code snippets like this. I can't find the documentation on these keywords. Any ideas? nope, not the manpage :)

Q2: If possible I would like to change K to (the tried and failed) half-page-up, or even to something like "go up 5 lines", to preserve context.

Tried and failed:

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!

Upvotes: 1

Views: 472

Answers (2)

Yury Ershov
Yury Ershov

Reputation: 424

Unfortunately, this part is not documented well in tmux.

This is the full list of 'copy mode' commands in version 2.2 ripped out from the source code:

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

All these commands apply to both vi-copy and emacs-copy modes but behavior might differ making it consistent with vi or emacs, though.

There are some shortcomings when tmux is 'in mode':

  • No sensible commands list or tab-completion for 'mode' commands
  • No way to combine commands in 'mode': you can only bind one action to a keypress and the set of actions is limited.

There's also a patch addressing these problems: http://ershov.github.io/tmux/

It adds full-fledged scripting support into tmux.

Using that, you can list all available commands:

info commands ::tmux::*

List all 'mode' commands:

info commands ::tmux::mode::*

List all 'copy mode' commands:

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

Bind multiple actions in copy-mode:

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

Upvotes: 0

Brett Y
Brett Y

Reputation: 7688

You can use tmux list-keys -t vi-copy to see a list of all the functions that are mapped in vi-copy mode. If you wish to see all possible commands you can look at the source code, specifically mode-key.c. I don't think there are any docs that list them all.

The mappings you are looking for are:

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

Upvotes: 2

Related Questions