I’m trying to stop using the arrow keys in vim. But instead of setting them to <nop>, as other people do, I want them to show an error message. This does the thing in normal mode:
noremap <up> :echoerr 'USE K TO GO UP'<CR>
noremap <down> :echoerr 'USE J TO GO DOWN'<CR>
noremap <left> :echoerr 'USE H TO GO LEFT'<CR>
noremap <right> :echoerr 'USE L TO GO RIGHT'<CR>
I tried to do the same in insert mode, but it didn’t work:
inoremap <up> :echoerr 'USE K TO GO UP'<CR>
inoremap <down> :echoerr 'USE J TO GO DOWN'<CR>
inoremap <left> :echoerr 'USE H TO GO LEFT'<CR>
inoremap <right> :echoerr 'USE L TO GO RIGHT'<CR>
This instead prints :echoerr 'USE K TO GO UP' where my cursor is when I press up in insert mode.
How can I fix the inoremap directives so this works as I expected? (also, an explanation of why it doesn’t work would help).
EDIT: Thanks to all the people that helped me. I ende up using this:
noremap <up> :echom 'USE K TO GO UP'<CR>
noremap <down> :echom 'USE J TO GO DOWN'<CR>
noremap <left> :echom 'USE H TO GO LEFT'<CR>
noremap <right> :echom 'USE L TO GO RIGHT'<CR>
inoremap <up> <ESC>:echom 'USE K TO GO UP'<CR>
inoremap <down> <ESC>:echom 'USE J TO GO DOWN'<CR>
inoremap <right> <ESC>:echom 'USE L TO GO RIGHT'<CR>
inoremap <left> <ESC>:echom 'USE H TO GO LEFT'<CR>
The vim-autoclose plugin was giving me trouble with the up/down keys on edit mode. I just uninstalled the plugin.
1 Answer