tags:

views:

62

answers:

3

I often jump from a file to file, while working a large codebase. I typically do this by way of putting cursor on the file, say foo.h, and typing "gf". I wonder if I can do the same thing, yet open the file in a split window.

One obvious solution is to simply type: vsp (sp) filename.

+4  A: 

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

<c-w>f for split window <-- this is the answer you are seeking

source: http://vim.wikia.com/wiki/Open_file_under_cursor

Amit Kumar
Nice -- I hadn't seen that before.
MikeSep
Yes, new to me too -- just discovered while trying to answer the question. For enjoying tabs, see: http://vimdoc.sourceforge.net/htmldoc/tabpage.html
Amit Kumar
A: 

When I do :sp or :vs, the new window is created, but my cursor is left on the same line. Thus, you could do :sp followed by gf. You could also make a shortcut command or mapping for that sequence.

MikeSep
A: 

I use a.vim plugin for this. http://www.vim.org/scripts/script.php?script_id=31

In addition to what you are looking for. I also has a feature in which you can alternate between header and cpp file very easily(if you work on c/cpp code). Its very handy sometimes

Yogesh Arora