Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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)

share|improve this question
    
Check out this. –  Emanuel Berg Jun 21 '13 at 15:37

1 Answer 1

up vote 8 down vote accepted

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).

share|improve this answer
    
Thanks, great answer, I have just realized I have different problem though - the emacs keys (C/M-v) don't put tmux in copy mode right after the tmux is activated, while N/PPage do. In other words when tmux copy mode is active I can use both types of keys, but to enter copy mode I should either use N/PPage or press copy-mode key. Should I create sep. q for it? I already feel like a pussy for not debugging/reporting it properly :( but I assumed the auto-copy-mode activation should work with both type of keys –  Evgeniy Dolzhenko Mar 5 '12 at 8:02
    
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 enter copy-mode one page up from the end. Check out the (non-table) bindings for PPage: tmux list-keys | grep -F page. There is no binding for NPage though (it does not make sense to go “down” in history because you are always at the bottom of history unless you are already in copy-mode; similarly there can be no sensible binding for C-v –  Chris Johnsen Mar 5 '12 at 8:17
    
It worked! Thanks a lot again! Sure totally makes sense to not have "down" bindings –  Evgeniy Dolzhenko Mar 5 '12 at 13:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.