I have the following settings in my .vimrc file which set vertical bar cursor for insert mode, :
"vertical bar cursor style (insert mode)
let &t_SI = "\<Esc>[6 q"
"underline cursor (replace mode)
let &t_SR = "\<Esc>[4 q"
"block cursor (default)
let &t_EI = "\<Esc>[2 q"
These settings work fine if vim is started in xterm, xterm -> tmux or urxvt terminal. However, the cursor doesn't change if I start vim from urxvt -> tmux sessition.
I've seen suggestions to use the following vim settings for tmux:
let &t_SI .= "\<Esc>Ptmux;\<Esc>\<Esc>[6 q\<Esc>\\"
let &t_SR .= "\<Esc>Ptmux;\<Esc>\<Esc>[4 q\<Esc>\\"
let &t_EI .= "\<Esc>Ptmux;\<Esc>\<Esc>[2 q\<Esc>\\"
The above works, but the problem is that the cursor is not saved/restored when I move between panes/windows. Its style changes globally. Once I enter vim insert mode, the cursor changes to bar, and stays like that in all windows/panes.
If I set TERM to xterm-256color instead of rxvt-unicode-256color, the cursor works fine, just like in xterm -> tmux session. however, there's a problem with F1-F4 keys, since urxvt uses different key mappings for them.
So it looks like tmux is the culprit in this vim cursor issue. Somehow tmux decides not to support cursor capabilities in the urxvt terminal.
For example, `echo -ne "\e[6 q"` works fine in urxvt, xterm, xterm->tmux sessions, but doesn't work in urxvt->tmux.
Please, help.