This is all in iTerm2 on OS X.
I used to have
.bashrc. This meant Vim in tmux did use 256 colors.
And once I added
set -g xterm-keys on
then keyboard shortcuts with modifiers worked fine in Vim. Namely:
shift+left/right that I mapped to switch Vim tabs,
ctrl+up/down that I mapped to move ("bubble") lines, and
shift+left/right which worked out of the box to jump by word in the command-line mode (e.g. when typing something like
:e foo bar baz).
However, this setup had the problem that the Vim background color only shows behind text, as mentioned here.
So I removed
.bashrc and instead put this in my
set -g default-terminal "screen-256color"
That fixed the Vim background color, but broke the keyboard shortcuts - they do unexpected things (move the cursor, delete text) instead.
ctrl+v to insert the verbatim output from the key combinations (as described here), I was able to work around it:
map [1;5A <C-Up> map [1;5B <C-Down> map [1;2D <S-Left> map [1;2C <S-Right> cmap [1;2D <S-Left> cmap [1;2C <S-Right>
This makes the shortcuts work, but it doesn't feel like the right solution. Could anyone tell me what's happening here and how to fix it?