Install either with vim-plug, Vundle, Pathogen or Neobundle.
This plugin provides enhanced version of the built-in :tab drop
command (if the file is already open in a tab then vim will switch to that tab instead of opening a new window). You can:
- Run
:Tabdrop path_to_open [line#], [col#]
to open specified path. Pass the optional line and column number if you want to jump to certain line and column. - Run
:NewTabdrop path_to_open [line#], [col#]
to perform exact the thing asTabdrop
except that the content in the current tab will always be hidden after drop. This might be useful for e.g. in vim-esearch. - Run
:TagTabdrop
to follow tags of word-under-cursor in a new/existing tabpage. - Run
:TabdropPushTag
to save the current location in a stack - Run
:TabdropPopTag
to jump back to the last location
For example, if you use LanguageClient-neovim to do code traversal, having the following config in your vimrc you can jump to function definition in a new (or existing) tab by pressing Ctrl+]
and jump back by pressing Ctrl-t
.
nnoremap <C-]> :call Gotodef()<CR>
nmap <C-t> :TabdropPopTag<Cr>
function! Gotodef()
TabdropPushTag
call LanguageClient_textDocument_definition({'gotoCmd': 'Tabdrop'})
endfunction
To have a unified mapping for both a language server and tags file. You can define the Gotodef
function as:
function! Gotodef()
TabdropPushTag
try
TagTabdrop
catch /E433:/
call LanguageClient_textDocument_definition({'gotoCmd': 'Tabdrop'})
endtry
endfunction
By default, if the target tab is different than the current tab, vim-tabdrop close the current tab on TabdropPopTag
command. To prevent from this, add the following snippet in your vimrc
let g:tabdrop_close_on_poptag=0