I don't use arrow keys, but to avoid the cursor moving should I hit them by mistake, I have this in my vimrc:
inoremap <Left> <NOP>
inoremap <Right> <NOP>
inoremap <Up> <NOP>
inoremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
noremap <Up> <NOP>
noremap <Down> <NOP>
I also don't like the idea of hitting ZZ
or ZQ
in normal mode by mistake, so I also have
nnoremap ZZ <NOP>
nnoremap ZQ <NOP>
And what about :help
opening if I mistakenly hith F1?
noremap <F1> <NOP>
lnoremap <F1> <NOP>
tnoremap <F1> <NOP>
Eventually I ended up adding the following too
nnoremap <CR> <NOP>
but soon discovered that was not a good idea, as I couldn't use Enter in the command window anymore. So I added
augroup NormalModeCarriageReturnIsNoOpExceptInCmdwin
autocmd!
autocmd CmdwinEnter * nunmap <CR>
autocmd CmdwinLeave * nnoremap <CR> <NOP>
augroup END
but doing some code navigation I've also noticed another place where I need Enter to keep its original meaning is in quickfix windows. However there's no such event as QuickfixWinEnter
/QuickfixWinLeave
.
So the question is: how can I deactivate Enter only when its effect would be the same as j (well, not exactly the same, but I don't care about their little difference)?