Search code examples
vimtagbar

How to jump next tag when using tagbar in VIM


when using VIM with tagbar displayed. I want to use the next command in .vimrc

nnoremap tn <C-w>h<cr>

to jump to the next tag in the tagbar. But the it takes no effect at all.

when i typed tn, the cusor is jumped to the next tag, but the main window keeps still

is there somebody can help me?


Solution

  • Normally, <CR> in normal mode just moves the cursor to the beginning of the next line. To make that key jump to the tag on the current line, the tagbar plugin defines a buffer-local mapping in its tag window. Though it's generally recommended to use :nnoremap, this is one case where you have to allow remappings by using :nmap:

    :nmap tn <C-w>h<cr>