Jump to the filename under the cursor
Vim treats filenames in our document as a kind of
hyperlink. When configured properly, we can use
the gf
command to go to the filename under the
cursor.
Specify a file extension
The ‘suffixesadd’ option allows us to specify one or more file extensions, which Vim will attempt to use when looking up a filename with the gf command (:h ‘suffixesadd’ ). We can set it up by running this command:
:set suffixesadd+=.rb
Each time we use the gf command, Vim adds a record to the jump list, so
we can always go back to where we came from using
the
Specify the directories to look inside
In this example, each of the files referenced with the require statement was located relative to the working directory. But what if we referenced function- ality that was provided by a third-party library, such as a rubygem?
That’s where the ‘path’ option comes in (:h ‘path’ ). We can configure this to reference a comma-separated list of directories. When we use the gf command, Vim checks each of the directories listed in ‘path’ to see if it contains a filename that matches the text under the cursor. The ‘path’ setting is also used by the :find command
We can inspect the value of the path by running this command:
:set path?
❮ path=.,/usr/include,,
In this context, the . stands for the directory of the current file, whereas the empty string (delimited by two adjacent commas) stands for the working directory. The default settings work fine for this simple example, but for a larger project we would want to configure the ‘path’ setting to include a few more directories.