I'd like to be able to map emacs keys (like C-v
/M-v
) for scrolling in tmux instead of default PgUp
/PgDown
, is that possible? Can't see that from the manual at the moment (apologies if its there, seems like a such a natural thing considering the rest of the emacs-like navigation key bindings tmux uses)
-
Check out this.– Emanuel BergJun 21, 2013 at 15:37
1 Answer
By default, the emacs-copy
key binding table has all of C-v, Page Down (NPage
), and Space bound to page-down
as well as both M-v and Page Up (PPage
) bound to page-up
.
You can check your bindings with tmux list-keys -t emacs-copy | grep -i page
.
If these bindings are missing you can reestablish them by hand (e.g. in your ~/.tmux.conf
):
bind-key -t emacs-copy C-v page-down
bind-key -t emacs-copy M-v page-up
But since these are the default, you will need to track down where they are being changed/removed before you will know where to put the above commands to make them effective (they will need to come after whatever else is modifying the bindings).
Are you sure your mode-keys
option is set to emacs
? It does default to emacs
, but tmux will set it to vi
(along with status-keys
) if you have the VISUAL environment variable set and its value has vi
in it†, or if you do not have VISUAL set but do have EDITOR set and its value has vi
in it.
You can check your global mode-keys
value with tmux show-options -g -w | grep mode-keys
. You may also have a per-window mode-keys
value (omit the -g
to check its value; you may use -t
to target another window if you can not run the command in the window itself).
If you want to override the “auto-detection” and always use the emacs
binding tables, then you can put these lines in your ~/.tmux.conf
:
set-option -g status-keys emacs
set-option -gw mode-keys emacs
† The “has vi
in it” test is actually more like “vi
occurs after the last /
(or anywhere if there /
does not occur in the value)”. This means that a value like /opt/vital/bin/emacs
will not count as vi
(despite the vi
in vital
).
-
It sounds like you want to do this:
bind-key M-v copy-mode -u
. Then you can type two keystrokes («Prefix» «M-v») to entercopy-mode
one page up from the end. Check out the (non-table) bindings forPPage
:tmux list-keys | grep -F page
. There is no binding forNPage
though (it does not make sense to go “down” in history because you are always at the bottom of history unless you are already incopy-mode
; similarly there can be no sensible binding for C-v Mar 5, 2012 at 8:17 -
It worked! Thanks a lot again! Sure totally makes sense to not have "down" bindings Mar 5, 2012 at 13:18