VIM: disable cursor / arrow keys but only for navigation

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 with hjkl :)

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

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

+49
vim
Mar 20 2018-11-11T00:
source share
7 answers

Add the following to the .vimrc file:

 " Disable Arrow keys in Escape 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> 
+24
Sep 14 '13 at 19:38
source share

You can view the history using Cn and Cp (Ctrl + n and Ctrl + p, respectively).

+23
Oct 15
source share

The code you posted should not turn off history navigation in command line mode, you are sure that you do not have cnoremap <Up> <Nop> or noremap! <Up> <Nop> noremap! <Up> <Nop> somewhere? Try verbose cmap <Up> , it should show you if the <Up> key is overridden for command line mode.




If you meant the command line window when writing "command line", you can try the following:

 nnoremap <expr> <Up> ((bufname("%") is# "[Command Line]")?("\<Up>"):("")) 
+8
Mar 20 2018-11-11T00:
source share

For me this works:

 map <Left> <Nop> map <Right> <Nop> map <Up> <Nop> map <Down> <Nop> 

Taken from: https://github.com/garybernhardt/dotfiles/blob/master/.vimrc#L148

+5
Apr 26 '13 at 8:35
source share

Change noremap to nnoremap to apply mappings to normal mode, otherwise they will be global mappings of all modes.

0
Mar 20 2018-11-11T00:
source share

Use q: to open a split window of your command line. You can normally navigate inside it, as this is a normal vim window using hjkl and other normal vim movements, and press enter to run the command under the cursor.

Do not use the arrow keys to navigate command line history.

By the way, can you also access your search history with q/ or q? .

0
Feb 11 '15 at 14:20
source share

You can also reinstall them to move between split windows. This disables the arrow keys for directional movement within the file, but allows navigation between split windows.

 noremap <up> <Cw><up> noremap <down> <Cw><down> noremap <left> <Cw><left> noremap <right> <Cw><right> 
0
Feb 09 '17 at 13:50
source share



All Articles