I've read that in insert mode in vim
, one can use <C-Left>
and <C-Right>
to move by words. This works for me, but only as far as I don't run vim
inside tmux
terminal splitter.
When inside tmux
, <C-Left>
instead throws me out of the insert mode and gives an error:
E388: Couldn't find definition
This error is explained in the help to have something to do with definition searching. However, I don't want any definition to be searched for, I want just to move one word to the left. As well, <C-Right>
does nothing more than throwing me out of the insert mode, not what I would like.
Reading somewhere that this might be connected to set (no)esckeys
, I tried it with both settings of this flag, with the very same result. As well, I have seen the answers in How to get shift+arrows and ctrl+arrows working in Vim in tmux? but they don't appear to help me.
My current .tmux.conf
:
# This File is : ~/.tmux.conf
# use "|" and "-" to do vertical/horizontal splits
# (press CTRL B and then - or |, CTRL D to close it)
unbind %
bind | split-window -h
bind - split-window -v
# use the vim motion keys to move between panes
# (press CTRL B and then h,j,k,l for the move)
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# use vim motion keys while in copy mode
# To copy, press CTRL B and then [, move, space, move, enter.
# To paste, press CTRL B and then ]
setw -g mode-keys vi
# make vim work properly inside tmux
setw -g xterm-keys on
set -g default-terminal "screen-256color"
And .vimrc
:
" tabs, indentation, line numbering
set ts=4 sts=4 number autoindent sw=4
" sage is python
au BufNewFile,BufRead *.sage set filetype=python
if &term =~ '^screen'
" Page keys http://sourceforge.net/p/tmux/tmux-code/ci/master/tree/FAQ
execute "set t_kP=\e[5;*~"
execute "set t_kN=\e[6;*~"
" Arrow keys http://unix.stackexchange.com/a/34723
execute "set <xUp>=\e[1;*A"
execute "set <xDown>=\e[1;*B"
execute "set <xRight>=\e[1;*C"
execute "set <xLeft>=\e[1;*D"
endif