Basically, I’m editing files that have include file names and I want a quick way of opening the file without having to type the path/filename:
include('inc/doctype.inc.php');
Is there an easy way to do this? (Ideally, I’d like to use :tabnew to open the file in a new tab.)
Thanks.
Use the gf shortcut. Move your cursor on a path string, the exact cursor position is not important and then press gf in normal mode. gf stands for “goto file”.
See vims help page with
:h gf:To get back, use Ctrl-o in normal mode.
Note: This command brings the cursor position to older positions in the jump list. The opposite command is Ctrl-i which brings the cursor to newer positions in the jump list.