Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have installed tags so I can jump to a function body in another file via CTRL + ]
I know that I can do gf to jump to another file.
I know that I can do CTRL-w s to split the vim window.
What I don't know and I am very interested in, is how can I combine the first 2 with the last.
I.e. how could I jump to another file via tag or gf opening the file in a separate tab?

share|improve this question
possible cross site duplicate of: stackoverflow.com/questions/908269/… – Ciro Santilli 巴拿馬文件 六四事件 法轮功 Sep 15 '14 at 15:05
up vote 4 down vote accepted

You can split and open a new file at the named tag with the command :stag, it appears to default to the binding Ctrl-w, Ctrl-].

You could bind that to whatever then:

map <F2> :stag

If needs to be done in a tab, then, you can do it in two steps:

Ctrl-w,Ctrl-] Ctrl-w, T

Or you can map it:

map <F2> :tab split <CR>:exec("tag ".expand("<cword>"))<CR>

For the gf equivalent of opening in new tab


or window split:


And again if you want to split AND then open in new tab,

Ctrl-w,f Ctrl-w, T

share|improve this answer
Yeap. This works for ctags +1. How about gf? – Jim Aug 13 '13 at 21:18

Your Answer


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.