I have ctags configured with my vim installation. My habit is to usually have all of the relevant files I'm working on open in tabs in vim all at once. The "problem" is that if I use Ctrl+] to jump to a ctag in a file I'm editing, it will replace the buffer in that tab, even though I have another tab already open containing that symbol. It would be much better if it just switched to that tab and jumped to the symbol there instead. This way I would always have a 1-to-1 tab-to-file ratio.
I noticed in the Changenotes for the taglist.vim plugin (which I also use) has an entry that says
1. Added support for jumping to a tag/file in a new or existing tab from the taglist window (works only with Vim7 and above).
However, I couldn't find anything in the documentation for Taglist (or Ctags) about how to actually do this.
Can any vim gurus fill me in? Thanks!
Best Answer
You can do this with
:tab tag NAME_OF_TAG
, but that isn't mapped to anything. You could remap<Ctrl-]>
to do that as follows in your .vimrc file:<c-r><c-w>
will grab the word under the cursor and<cr>
is the final enter/carriage return to run the command.EDIT: oh no, I re-read the question. This will open a new tab each time, which sucks!!
According to the taglist help page:
And indeed pressing
t
in the taglist pane does this, but it means you had to already have the tag visible in the taglist pane. And that too is a bit lame...