1

When in tmux copy mode, I'd like to move the cursor with some Alt+key combos rather than the arrows. Is there a way to make tmux do this?

Here are the definitions I'd like:

Alt+i: up Alt+l: right Alt+j: left Alt+k: down Alt+o: forward word Alt+u: backward word 

I do not want to switch tmux over to vi mode.

2 Answers 2

2

Turns out you have to edit the key bindings for the emacs-copy table. Here's how I made the changes that I wanted above.

First, I checked out what the current bindings were by entering the following command in tmux (by pressing Prefix+colon) list-keys -t emacs-copy. This gave me a list of the keys that were bound in emacs-copy mode and I looked through them to figure out which commands did what I wanted.

Then, I added the appropriate key bindings to my ~/.tmux.conf file like so:

bind-key -t emacs-copy M-j cursor-left bind-key -t emacs-copy M-i cursor-up bind-key -t emacs-copy M-l cursor-right bind-key -t emacs-copy M-k cursor-down bind-key -t emacs-copy M-u previous-word bind-key -t emacs-copy M-o next-word 

Finally, I ran the tmux command source ~/.tmux.conf inside tmux to get the keys bound without having to exit and reload the session.

1

This (apparently) has changed in more recent tmux versions: In 2.9a, there does not seem to be an emacs-copy key table (but there's a copy-mode), and the bind-key argument for key tables is (only) -T (note upper case). So to e.g. have Ctrl-Left/Right jump words in copy/mode:

bind-key -T copy-mode C-Left send-key -X previous-word bind-key -T copy-mode C-Right send-key -X next-word 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.