There is a big issue since I started to use Vim, using Vim with terminal multiplexer such as GNU/Screen or tmux, there is always some issue comes from nowhere and you wouldnt have if you just use Vim in xterm or urxvt.
I had been navigating in my files with a silly way: Press Left/Right key to go up/down in a line. There is a faster way: Press Shift+Left/Right to move backward/forward a word. But it never worked when I was in Screen or tmux.
I googled it and got the solutions, and knew the exactly the problem is. If you look at the key control codes (returned by cat -v), you will see the problem.
$TERM | Left | S-Left | C-Left |
---|---|---|---|
xterm | ^[[D | ^[[1;2D | ^[[1;5D |
rxvt-unicode | ^[[D | ^[[d | ^[Od |
screen | ^[[D | ^[OD | ^[OD |
For xterm and urxvt, they both have correct reaction in Vim; for Screen and tmux (tmux uses screen as $TERM), they havent and they are worse because there is no distinguish between Shift+Left and Ctrl+Left, but for former problem its fixable.
There are a few ways to fix it, I decided to remap the keys. And I have these in my .vimrc:
map ^[OC <Right> map ^[OD <Left> map ^[[C <S-Right> map ^[[D <S-Left>
You can not just copy them to your .vimrc, you have to input ^[OC by pressing in insert mode: Ctrl+V,
0 comments:
Post a Comment