Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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!

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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:

:nmap <c-]> :tab tag <c-r><c-w><cr>

<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:

The following table lists the description of the keys that can be used in the taglist window.

t Jump to the tag in a new tab. If the file is already opened in a tab, move to that tab.

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...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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