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?
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>
You can cycle through the history using C-n
and C-p
(Ctrl+n and Ctrl+p, respectively).
The code you have posted should not disable history navigation in command line mode, are you sure you don't have cnoremap <Up> <Nop>
or noremap! <Up> <Nop>
somewhere? Try verbose cmap <Up>
it should show you whether <Up>
key is redefined for command line mode.
If when saying «command bar» you meant command-line window, you could try the following:
nnoremap <expr> <Up> ((bufname("%") is# "[Command Line]")?("\<Up>"):(""))
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
Use q:
to open a split window of your command line. You can navigate within it normally, as it's a regular vim window using hjkl
and the other usual vim motions, and hit enter to run the command under cursor.
Don't use the arrow keys to navigate in the command line history.
Incidentally, you can also access your search history using q/
or q?
.
You may also consider remapping them to move between the split windows. This disables the arrow keys for directional movement inside the file but lets you move between the split windows.
noremap <up> <C-w><up>
noremap <down> <C-w><down>
noremap <left> <C-w><left>
noremap <right> <C-w><right>
Change noremap
to nnoremap
to apply the mappings to normal mode, otherwise they're global all-modes mappings.
精彩评论