Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

open a file under cursor in a split window

Tags:

vim

vi

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.

like image 746
vehomzzz Avatar asked Mar 12 '10 15:03

vehomzzz


People also ask

How to open file under cursor in vim?

Put the cursor on the filename and type gf (in command mode). Or use CTRL + W | CTRL + F to open in another window.

How to open include file in vim?

Use the g f shortcut. Move your cursor on a path string, the exact cursor position is not important and then press g f in normal mode. g f stands for "goto file".

How do I revert to a previous version of Vim?

CTRL-^ Edit the alternate file. Mostly the alternate file is the previously edited file. This is a quick way to toggle between two files. It is equivalent to ":e #", except that it also works when there is no file name.


1 Answers

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

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

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

like image 64
amit kumar Avatar answered Sep 23 '22 15:09

amit kumar