19 Jan 2014 21:38:19

Tmux Vim and <S-Tab> (Shift) keybindings problems

If you start vim on top of tmux some keybindings won't be working. I solved it for myself here is solution.



First set up correct $TERM bash variable for your terminal. I'm using urxvt there is mine:
 
# if you don't use zsh replace it by  ~/.bashrc
echo "export TERM=rxvt-256color" >> ~/.zshrc 
There is main solution type cat in your terminal (under started tmux)
cat
And then just type Shift+Tab you should see something like this
terminal > cat                                                                                                                                                                   
^[[Z
  Then we should map this sequence within vim, please use your own char sequence if it's differ from mine I use next config to identify is current terminal session under tmux & bind proper key rely on check.
vim ~/.vimrc
let g:Tmux = system('echo $TMUX') let g:Tmux = substitute(g:Tmux,"\\s\\|\\n\\|\\r","","g") " Consider tmux keybinds handling. if g:Tmux != '' nnoremap <silent> ^[ :call MRU_toggle()<CR> else nnoremap <silent> <S-TAB> :call MRU_toggle()<CR> endif
Please note to type ^[ prefix character in vim you should enter insert mode & type
<C-V> + Esc
If you type it as plain text it won't be work

Comments:

add comment

Image CAPTCHA