In Vim, I had set the Ctrl+Arrow keys to skip words. This works just fine when running Vim inside the gnome-terminal.
However, when using byobu (tmux), it shows weird behavior : it deletes everything after the cursor.
For reference, these are my vim settings:
:inoremap <C-Left> <C-\><C-O>b
:inoremap <C-Right> <C-\><C-O>w
Best Answer
The problem is twofold. First,
tmux
by default converts the control-arrow keys from one type of escape sequence to another. So special keys such as controlleft are sent tovim
without the modifier, e.g., left. If you usecat -v
to see the different escape sequences, you might see something like thisversus this (outside tmux):
The line
fixes that aspect. The other part is that
tmux
by default uses the terminal description forscreen
. That terminal description does not describe the control-arrow keys. These entries from the terminal database would be the most appropriate for VTE (gnome-terminal):There are others, such as
which would be automatically selected when running in
screen
if the correspondingTERM
outside werevte
,vte-256color
, etc.tmux
does not do this automatic-selection; you have to modify its configuration file.By the way, there is no "screen.xterm" entry because it would interfere with some usages of
screen
. There is no conflict withTERM=xterm-new
.If you have a default (minimal) terminal database such as
ncurses-base
in Debian, you might not have those. More common would bexterm-256color
, which is close enough to use with vim and tmux.For example, if I add this to my
.tmux.conf
file, it behaves as you expect in vim:Further reading: