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?
Opening a tab Probably the easiest to remember is to run the :tabnew command while in normal mode. This will open a new tab with an empty buffer. If you want to edit a file in the new tab, you can run :tabnew filename and Vim will load the file in the new tab.
To use the tags file, you'll need to open Vim and tell it where it is. Still in the Vim source directory, I ran vim and then typed :set tags+=tags to tell it to use the ./tags file. At this point, Vim knows about the tags file — you don't need to tell it to load the file.
In gnome-terminal, I can just press Alt + ( 1 , 2 , 3 , etc.) to switch to specific tabs. I can also use Ctrl + ( PgUp / PgDn ) to cycle through tabs (admittedly less convenient, but it can be remapped). If I want to use vim tabs instead of gnome-terminal tabs, typing :tabn and :tabp is quite cumbersome.
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://stackoverflow.com/questions/563616/vimctags-tips-and-tricks
"--------------------
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>
You can also open tags in preview :ptag
with C-w}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With