I'm using Vim that's running inside a tmux session. Within Vim, I have Ctrl-Right bound to :tabnext:
map <C-right> :tabnext<CR> "next tab
I want to be able to invoke this binding even when Vim is inside tmux, so I added the following to my .tmux.conf:
bind-key -n C-Right send-keys C-Right
But this doesn't have any discernible effect on either Tmux or Vim! What am I doing wrong here?
Thanks in advance.
I got something working though I'm very much treading unknown territory here. Perhaps someone else can fill in the rest.
The first difference I noticed when starting up Vim in the terminal and Vim inside tmux was in their 'term'
setting.
When asked :set term?
, ordinary terminal Vim answered xterm-256color
, but tmux Vim answered screen
. It's important to understand that the exact key codes sent in the terminal depend on the type of the terminal.
One solution is simply to make tmux and Vim speak the same language. In tmux:
set-option -gw xterm-keys on
bind-key -n C-Right send-keys C-Right
In Vim:
:set term=xterm-256color
Now Vim and tmux understand each other's terminal key codes and your key strokes will make it all the way to Vim.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With