VIM: disabling the cursor/arrow keys, but only for navigation

后端 未结 7 1937
自闭症患者
自闭症患者 2021-02-01 00:52
inoremap       
inoremap     
inoremap     
inoremap    
noremap             


        
相关标签:
7条回答
  • 2021-02-01 01:08

    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> 
    
    0 讨论(0)
  • 2021-02-01 01:16

    You can cycle through the history using C-n and C-p (Ctrl+n and Ctrl+p, respectively).

    0 讨论(0)
  • 2021-02-01 01:16

    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?.

    0 讨论(0)
  • 2021-02-01 01:20

    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

    0 讨论(0)
  • 2021-02-01 01:22

    Change noremap to nnoremap to apply the mappings to normal mode, otherwise they're global all-modes mappings.

    0 讨论(0)
  • 2021-02-01 01:25

    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>
    
    0 讨论(0)
提交回复
热议问题