1

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/
  • 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' Jan 14 '17 at 1:27
  • @G-Man When the A appears its because I pressed the up arrow – Nicholas Adamou Jan 14 '17 at 1:27
  • @G-Man And yeah your right. Should be easier to understand. – Nicholas Adamou Jan 14 '17 at 1:28
  • @G-Man I made the Gif more understandable using Keycastr – Nicholas Adamou Jan 14 '17 at 1:48
  • Out of curiosity... why? – Nic Hartley Mar 7 '18 at 22:31
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.

  • 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. – Nic Hartley Mar 7 '18 at 22:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.