Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to disable arrow keys in Vim

📅 2013-Feb-07 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive

Vim experts keep chanting that to really learn and love Vim, one must use the insert mode for the tiniest period of time and get out of it as soon as possible. However, this is a difficult skill to learn. This is because one can easily navigate in all directions in both insert and normal mode using the arrow keys.

So, one has to be forced to navigate using only hjkl keys. These keys cannot be used in insert mode, so one is forced to quit insert mode as soon as possible and learn other tricks to repeat edits.

Steve Losh recommends disabling the arrow keys for learning this skill. I was initially skeptical, but it worked extremely well for me within just 2 days!

To disable the arrow keys, add this to your vimrc:

nnoremap <up>    <nop>
nnoremap <down>  <nop>
nnoremap <left>  <nop>
nnoremap <right> <nop>
inoremap <up>    <nop>
inoremap <down>  <nop>
inoremap <left>  <nop>
inoremap <right> <nop>

Tried with: Vim 7.3 and Ubuntu 12.04 LTS