The arrow keys, even when disabled in vimrc, type ABCD then go into insert mode. Why?

1

0

When I hit the arrow keys in vim I get the behavior illustrated in this illustrated Gif.

I would like to only use hjkl to navigate. Any time I hit the arrow keys (up, down, left or right) I want it tell me to one of the hjkl keys. For example, when I press the up arrow key, I want it to say: Use k and not put me into insert mode or type A.


I added the following to my .vimrc file:

noremap <up> <nop>
noremap <down> <nop>
noremap <left> <nop>
noremap <right> <nop>

nnoremap <Left> :echoe "Use h"<nop>
nnoremap <Right> :echoe "Use l"<nop>
nnoremap <Up> :echoe "Use k"<nop>
nnoremap <Down> :echoe "Use j"<nop>

Thing's I've tried

I have set nocompatible in my ~/.vimrc (vimrc pastebin).

I am using vim-plug to manage my vim plugins.

Here is a list of my vim plugin directories in ~/.vim/bundles/:

ctrlp.vim/
emmet-vim/
fzf.vim/
gulp-vim/
git_status.vim/
gist-vim/
nerdtree/
nerdtree-git-plugin/
scss-syntax.vim/
syntastic/
tComment/
vim-autoformat/
vim-bundler/
vim-coffee-script/
vim-coloresque/
vim-endwise/
vim-eunuch/
vim-fugitive/
vim-go/
vim-mkdir/
vim-multiple-cursors/
vim-projectionist/
vim-pug/
vim-rails/
vim-rake/
vim-rhubarb/
vim-ruby/
vim-run-interactive/
vim-slim/
vim-surround/
vim-test/
vim-tmux-navigator/
webapi-vim/

Nicholas Adamou

Posted 2017-01-14T00:27:18.157

Reputation: 151

Please explain the behavior you’re getting.  Not knowing what you typed, it’s hard to make sense of your GIF.  (And, maybe, you might want to re-record it, to make the second part (after vim starts) slower (more time between keystrokes), so it’s easier to see what’s happening.)   Please do not respond in comments; [edit] your question to make it clearer and more complete. – G-Man Says 'Reinstate Monica' – 2017-01-14T01:27:10.723

@G-Man When the A appears its because I pressed the up arrow – Nicholas Adamou – 2017-01-14T01:27:45.753

@G-Man And yeah your right. Should be easier to understand. – Nicholas Adamou – 2017-01-14T01:28:17.940

@G-Man I made the Gif more understandable using Keycastr – Nicholas Adamou – 2017-01-14T01:48:39.083

Out of curiosity... why? – Fund Monica's Lawsuit – 2018-03-07T22:31:16.947

Answers

0

After hours of work. I guess I have found this times, at least for myself. If this doesn't work for you, I am sure this problem something about map commands. Try to disable all of them one by one. See, if something you can do.

Delete this line:

map <esc> :noh

This cause the problem for me and I don't know why. You can do :let @/="" instead.

Kutsan Kaplan

Posted 2017-01-14T00:27:18.157

Reputation: 116

This is likely because arrow keys are actually sent as multiple characters, with <esc> as the first. You could probably get the same result by moving that line to after the ones for the arrow keys, depending on if Vim continues looking for matches after rejecting its first candidate (which is, IMO, the most likely). In contrast, <esc> successfully matches when you hit an arrow key, so the rest gets effectively ignored. – Fund Monica's Lawsuit – 2018-03-07T22:31:56.673