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?


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

  • 1
    Yeap. This works for ctags +1. How about gf? – Jim Aug 13 '13 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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