I've mapped 'L' and 'H' to change buffers in vim. I often end up hitting these keys in NERDTree and Tagbar.

I'm able to use NERDTreeAddKeyMap to make NERDTree ignore keys. Tagbar only allows the use of g:tagbar_map_.* to replace key bindings that exist.

Is there a way I can make 'H' and 'L' do nothing in the Tagbar?

2 Answers 2


You can use a FileType autocmd and map those keys to <Nop>:

augroup TagBar
    autocmd FileType tagbar nnoremap <buffer> H <Nop>
    autocmd FileType tagbar nnoremap <buffer> L <Nop>
augroup END

Also always remember to enclose your autocmds with a augroup.

  • "I used nmap here instead of nnoremap, because <Nop> cannot be remapped." Use non-recursive mappings by default. Only use recursive ones when you really need them (which is not the case here.) Get into the habit of always using non-recursive mappings. See also excellent advice here: learnvimscriptthehardway.stevelosh.com/chapters/…
    – filbranden
    Commented Aug 7, 2019 at 1:27
  • 1
    @filbranden You're right! I rolled my edit back :)
    – ruohola
    Commented Aug 7, 2019 at 5:39
  • 1
    👍 That's much better, thanks!
    – filbranden
    Commented Aug 7, 2019 at 5:41

You can easily do this with <buffer>-specific mappings. Like this:

autocmd FileType tagbar nmap <buffer>H <Nop>
autocmd FileType tagbar nmap <buffer>L <Nop>
  • 1
    Any reason not to use nnoremap?
    – D. Ben Knoble
    Commented Aug 6, 2019 at 13:03
  • @D.BenKnoble I believe <Nop> cannot be remapped, so there's absolutely no reason to use nnoremap.
    – Matt
    Commented Aug 6, 2019 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.