Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open file from complete path under cursor in Vim

Tags:

command

vim

If I have a file that contains a complete path for a file, is there a way to highlight the filename (using visual mode) and open the file (preferably in a split screen)?

Here is the behavior I would like: if the file name contains a / character, assume it is a full path (i.e. the current directory is root). Otherwise, use the current folder (i.e. default behavior). Is this possible?

like image 470
David Oneill Avatar asked May 17 '10 14:05

David Oneill


2 Answers

Put the cursor on the filename and type gf (in command mode). Or use CTRL+W | CTRL+F to open in another window. See also :help gf (no, it's not your girlfriend).

like image 50
catchmeifyoutry Avatar answered Sep 24 '22 01:09

catchmeifyoutry


gf command opens file under cursor.

like image 30
Grzegorz Gierlik Avatar answered Sep 25 '22 01:09

Grzegorz Gierlik