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.

In ~/.tmux.conf, with

 bind-key v split-window "vim"

I can launch vim in a split window.

how I can use two keys in a tmux bind-key ?
Example:

 bind-key vG split-window "vim +$"
share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

You cannot. tmux only allows single-key bindings (either alone, using bind-key -n, or following the prefix key).

However, you might try binding "v" to an invocation of command-prompt:

bind-key v command-prompt "tmux-vim.bash %%"

where tmux-vim.bash looks something like

if [ $1 = "G" ]; then
    tmux split-window "vim +$"
fi

Then, after typing v to get to the command prompt, you would just type "G" and press Enter. "G" would be passed as the argument to tmux-vim.bash, and that script would take care of executing the tmux command you (originally) wanted to associate with "vG".

share|improve this answer
1  
    
You'd think I would have remembered answering that well enough to link to it myself :) –  chepner Jul 10 '12 at 12:32
add comment

As @chepner said, you cannot do this directly. What you can do is bind v to create a binding for G that does what you want and then unbinds itself.

bind-key v bind-key -n G split-window "vim +$" \\; unbind -n G

There are a couple of important things to note with this approach:

  1. This will conflict with existing top-level bindings (in this case G); If you want to have something bound to G and something else bound to vG your unbinding step needs to restore the original binding.
  2. tmux will segfault if your .tmux.conf includes a bind-key statement that is too long. If this becomes a problem, you can work around it by putting your context switching in bash scripts and then bind a key to run those scripts.

For a more involved example, see this gist.

share|improve this answer
add comment

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.