
Vim - Navigating files in vertical splits - skwp
http://yanpritzker.com/2012/03/12/vim-navigating-files-in-vertical-splits/
======
falcolas
The article mentions using Ctrl-O for navigating backwards in your jumps, but
much more useful for going through tags (Ctrl-]) is Ctrl-T. This way, you can
dive into a tag, go anywhere in that file (or subsequent files), and Ctrl-T
will pop you back to where you followed the tag from.

If you have ambiguous tags (such as an open() method that is found across
several different classes and files), you can use :ts to pick the right method
to go to, and not lose your tag navigation stack.

Ctrl-] and Ctrl-T, once you set up tags for your project, are indispensable
when traversing through code.

~~~
Alexandervn
Nice, I didn't know Ctrl-T. I usually use ^ or g; to go back.

------
hesselink
To open a tag in a tab instead of a split, I use:

map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR>

~~~
TomNomNom
And to open a file under the cursor in a tab you can use:

    
    
      <C-w>gF
    

I map it to F9 along with a :tabm to make the new tab the last one in the
list:

    
    
      nmap <F9> <C-W>gF:tabm<CR>
    

It's worth noting that if the filename has a colon followed by a line number
on the end of it, your cursor will be placed on that line. E.g, <F9> with the
cursor on the following:

    
    
      ~/.vimrc:40
    

Would open ~/.vimrc in a new tab, make it the last tab and place your cursor
on line 40.

Grep and ack (and I'm sure other tools) use this line number format in their
output when searching across multiple files. I often make use of this by
piping the output of such a command into a new vim buffer:

    
    
      grep -Hnri 'some string or other' * | vim -
    

Then I use vim to search, further filter and open the files in tabs with my
<F9> mapping, jumping straight to the specific line that matched my original
search.

