Reputation: 6973
When I use the arrow keys in vim in insert mode I get letters inserted instead of movement.
Does anyone know what would cause this?
Thanks in advance
Upvotes: 3
Views: 4667
Reputation: 8802
None of the answer here worked for me. I'm in Linux, with konsole/yakuake terminal and tmux. This fix works for me:
nnoremap <silent> <ESC>OA <ESC>ki
nnoremap <silent> <ESC>OB <ESC>ji
nnoremap <silent> <ESC>OC <ESC>hi
nnoremap <silent> <ESC>OD <ESC>li
inoremap <silent> <ESC>OA <ESC>ki
inoremap <silent> <ESC>OB <ESC>ji
inoremap <silent> <ESC>OC <ESC>hi
inoremap <silent> <ESC>OD <ESC>li
Upvotes: 1
Reputation: 183
The following worked for me. Just put it in your .vimrc
:set term=cons25
Upvotes: 4
Reputation: 652
:echo $HOME
.:set nocompatible
Reference: http://vim.wikia.com/wiki/Fix_arrow_keys_that_display_A_B_C_D_on_remote_shell
Upvotes: 2
Reputation: 53604
If these keys work fine in normal mode, but do not in insert then you must have some mappings to the first one or two characters (normally <Up>
is either <Esc>[A
(terminals that use CSI) or <Esc>OA
(xterm)). Try checking out output of
verbose imap <Esc>
, there should be not much mappings starting with <Esc>
in insert mode (I have none, for example). I can say, that with arrow keys working normally in insert mode, using
inoremap <Esc> <Esc>
produces just the same behavior as if you had problems with terminal recognition or had 'compatible' set.
Upvotes: 7
Reputation: 28525
Your vim
seems to be starting in the vi
compatibility mode. Do this
echo $HOME
$HOME
location,(if you don't have create it).vimrc
file
:set nocompatible
Find more solutions for the same problem here ( Especially if your problem is terminal related, the re-mapping of keys solution might work for you )
Upvotes: 7