Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM: disabling the cursor/arrow keys, but only for navigation

Tags:

vim

inoremap  <Up>     <NOP> inoremap  <Down>   <NOP> inoremap  <Left>   <NOP> inoremap  <Right>  <NOP> noremap   <Up>     <NOP> noremap   <Down>   <NOP> noremap   <Left>   <NOP> noremap   <Right>  <NOP> 

This is what I use to disable cursor navigation, to help me stick to hjkl :)

But it also disables the cursor on the command bar... normally the arrow keys let you cycle through the history

Is it possible to disable the cursor keys ONLY for navigation, and not for the history?

like image 224
user537339 Avatar asked Mar 20 '11 09:03

user537339


People also ask

How do I turn off arrows in Vim?

Alternatively, you could use the CmdWinEnter autocmd event to unmap arrow keys for the command-line window. cnoremap works to disable the up arrows in command line mode..

Do you need arrow keys for Vim?

The vim editor is derived from vi. It also utilizes the same hjkl keys to replace the functionality of arrow keys. Among vim users, hjkl keys are preferred and advantageous to use. You never have to leave the first row, allowing you to be speedier while working in vim editor.

Can you disable the arrow keys?

Tap 'Layout & keys' Check or uncheck 'Arrow Keys'

Why does Vim use HJKL?

Vim uses hjkl because vi did. Vi used hjkl because its creator's keyboard didn't have physical cursor keys. Instead, the arrows were printed on the hjkl keys.


1 Answers

Add the following in your .vimrc file:

" Disable Arrow keys in Normal mode map <up> <nop> map <down> <nop> map <left> <nop> map <right> <nop>  " Disable Arrow keys in Insert mode imap <up> <nop> imap <down> <nop> imap <left> <nop> imap <right> <nop> 
like image 160
neo7 Avatar answered Oct 19 '22 21:10

neo7