I have the following lines in my .vimrc, which I thought would be more than sufficient:
nnoremap <left> <nop>
nnoremap <right> <nop>
nnoremap <up> <nop>
nnoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
The arrow keys don't do anything (as expected) in normal mode, but continue to function in insert mode. I've also tried imap
and that doesn't work either. Querying the mapping with inoremap <left>
confirms that the binding isn't getting overwritten by something else. I'm not sure what's going on.
As one last test, I started up vim with no vimrc with vim -u NONE
, then only ran the mappings. If I enter insert mode and hit an arrow key now, it inserts the letters A, B, C or D on a new line where my cursor is, which is completely not what I was expecting.
Tap 'Layout & keys' Check or uncheck 'Arrow Keys'
You might have gotten it by pressing the Alt key and the spacebar together, releasing them, and then pressing the M key. (The Alt+space shortcut opens the “system menu” from the little program icon in the top left corner, and M is the letter that selects Move in that menu.) To get rid of it, just press the Esc key.
Based on this page, you can do it with the following mappings.
noremap <Up> ""
noremap! <Up> <Esc>
noremap <Down> ""
noremap! <Down> <Esc>
noremap <Left> ""
noremap! <Left> <Esc>
noremap <Right> ""
noremap! <Right> <Esc>
I tested them and they work, but I do not currently understand why this magic works.
In particular, I am not sure why it is necessary to map twice, but it should be effective for solving your problem.
That insertion of A B C D rings a bell. You seem to have the problem described in Fix broken arrow key navigation in insert mode and Fix arrow keys that display A B C D on remote shell, and possibly a workaround implemented.
That interferes with the :imap
s to <Nop>
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With