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

1 Answer 1

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.

1
  • 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.
    – anon
    Mar 7, 2018 at 22:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .