vimtaglist

Taglist mapping of tab key


I have mapped the TAB key to move between windows as shown below.

map <TAB> ^W^W

It works for all the windows (for example split-screen) except for the taglist window. When I press the TAB key in the taglist window, it either does not goto next window. How can I override it?

I also configured following options in my .vimrc:

let Tlist_Show_One_File = 1
let Tlist_Exit_OnlyWindow = 1
let Tlist_WinWidth = 30

It works if I comment out following line in taglist.vim plugin file

nnoremap <buffer> <silent> <Tab> :call <SID>Tlist_Window_Move_To_File(1)<CR>

I tried adding following line in my .vimrc file, but it didn't work.

nnoremap <buffer> <silent> <Tab> ^W^W

Is there a cleaner way to do this?


Solution

  • You are right, the Taglist plugin creates its own buffer-local mapping for its sidebar.

    There's no general way to undo / override that. Fortunately, the Taglist plugin creates its sidebar with a particular name (__Tag_List__), so you can hook into that with an :autocmd:

    :autocmd BufEnter __Tag_List__ silent! nunmap <buffer> <Tab>
    

    The silent! suppresses errors if the mapping has already been cleared.