Opening (c)tags in new tab in (G)Vim
Asked Answered
A

3

19

Ctrl+w Ctrl+i and :stj is nice, but how do I jump to a tag (under the cursor) in a new tab in GVim/Vim?

Amnion answered 25/5, 2009 at 22:31 Comment(1)
A supercharged superset of this: #539731 : open on new tab only if in another file, and when closing the new tab jump back to the parent.Marseillaise
A
32

Similar question How to use multiple tabs when tagging to a function in Vim

It points out this wiki (which points back at stackoverflow) with these settings (seems to work ok in terminal, haven't tried gvim):

"--------------------
" Function: Open tag under cursor in new tab
" Source:   https://mcmap.net/q/55034/-vim-and-ctags-tips-and-tricks-closed
"--------------------
map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR>
"--------------------
" Function: Remap keys to make it more similar to firefox tab functionality
" Purpose:  Because I am familiar with firefox tab functionality
"--------------------
map     <C-T>       :tabnew<CR>
map     <C-N>       :!gvim &<CR><CR>
map     <C-W>       :confirm bdelete<CR>
Aspic answered 25/5, 2009 at 22:54 Comment(3)
That first link contained the magical nmap <C-Enter> <C-w><C-]><C-w>T which was exactly what I was looking for. Thanks!Amnion
This is really nice, but it always opens a new tab. What if the file is already opened in another tab? Is there a way to do it?Stud
@OlivierPons See my answer on this post to get it to reuse existing tabs: vi.stackexchange.com/questions/10014/…Gemination
I
1

You can also open tags in preview :ptag with C-w}

Ironist answered 25/1, 2019 at 6:14 Comment(0)
I
0

You can easy jump to tag in a new tab like this

<c-w>gf open in a new tab (Ctrl-w gf)

Also, you can open it in a split view:

<c-w>f  open in a new window (Ctrl-w f)

Check this - http://vim.wikia.com/wiki/Open_file_under_cursor

Inductance answered 10/3, 2017 at 22:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.