I want to map <leader>h
to :bprev<CR>
, with my leader key as \<space>
, so I wrote the following in my init.vim (I also have nnoremap <space> <Nop>
in my init.vim to override the default normal mode behaviour of <space>
):
nnoremap <space> <nop>
let mapleader = "\<space>"
nnoremap <leader>h :bprev<CR>
but I have airblade/vim-gitgutter installed which adds a delay to my mapping because of plugin mappings <space>hp
, <space>hu
, <space>hs
:
:verbose noremap <leader>h
n <Space>hp <Plug>GitGutterPreviewHunk
Last set from ~/.config/nvim/bundle/vim-gitgutter/plugin/gitgutter.vim
n <Space>hu <Plug>GitGutterUndoHunk
Last set from ~/.config/nvim/bundle/vim-gitgutter/plugin/gitgutter.vim
n <Space>hs <Plug>GitGutterStageHunk
Last set from ~/.config/nvim/bundle/vim-gitgutter/plugin/gitgutter.vim
n <Space>h * :bprev<CR>
Last set from ~/.config/nvim/init.vim
n <Space> * <Nop>
Last set from ~/.config/nvim/init.vim
Press ENTER or type command to continue
This question indicates that I can remap plugin bindings by writing my custom bindings in a .vim file in .config/nvim/after/plugin
, so I tried moving the definition of my mapping there instead along with <Nop>
bindings for <space>hp
, <space>hu
, <space>hs
, but that doesn't work because my <Nop>
mappings still delay the execution of my <space>h
mapping:
:verbose noremap <leader>h
n <Space>h * :bprev<CR>
Last set from ~/.config/nvim/after/plugin/keys.vim
n <Space>hp <Nop>
Last set from ~/.config/nvim/after/plugin/keys.vim
n <Space>hu <Nop>
Last set from ~/.config/nvim/after/plugin/keys.vim
n <Space>hs <Nop>
Last set from ~/.config/nvim/after/plugin/keys.vim
n <Space> * <Nop>
Last set from ~/.config/nvim/init.vim
How can I override these mappings so that they don't interfere? Also, I have yet to find a decent "best practice" to avoid these types of conflicts - does one exist?
EDIT: I have tried putting exe :mapclear
at the top of my new .config/nvim/after/plugin/keys.vim
, but that clears all keybindings from all my plugins and my init.vim which is ... less than satisfactory - however, I don't think it's a terrible idea to move all my keybindings here and not rely on plugin defaults.