Live data from Hacker News

Vim - Navigating files in vertical splits

yanpritzker.com

1–7 of 7 posts

Re: Vim - Navigating files in vertical splits

#2
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.

Re: Vim - Navigating files in vertical splits

#3
post #2

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 pic…

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

Re: Vim - Navigating files in vertical splits

#5

To open a tag in a tab instead of a split, I use: map :tab split :exec("tag ".expand(" "))

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

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

  nmap  gF:tabm
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, 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 mapping, jumping straight to the specific line that matched my original search.

Re: Vim - Navigating files in vertical splits

#6
post #2

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 pic…

What's the equivalent for emacs? I usually just M-, til I get back