Tmux copy mode: how to create your own command?

tmux

Solution

I have this in my tmux conf:

# vi-style controls in copy mode
set-option -g status-keys vi
set-window-option -g mode-keys vi

# v and y like vi in copy-mode
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection

Now after going copy-mode i can easily select words by:

vw

And copy with

y

In tmux you have to select something to copy. There is nothing like copying in normal mode as you know from usual vi/vim commands. Unfortunately you can only use one key (like `v` or `y`) for every tmux argument.

You can find more about tmux's vi movement commands here: https://superuser.com/a/197272/57890

Problem

I love Tmux and its copy mode with Vi commands, but I'm really annoyed by the fact that this mode is very far from being as efficient as real Vim. For example, there is no keybinding to just copy a word (yw), I must always "go to the beginning of a word" "begin selection", "go to the end of the word" then "finish selection". A lot of operations when I just need to do yw in vim. I searched a way to create my own "yw" command in Tmux copy mode. Chaining all the operations needed is a good idea, but a simple bind with commands separated by `;` just doesn't work (similar thing works in non-copy mode). Is there something I miss? Or is the copy mode of Tmux just limited and not as scriptable as I need it to be?

Original source