Let VIM locate the file for you…

A very nice feature of VIM is the ‘gf’ command (go to file), which will open the file under cursor.

However, if there is a line like this:

 import my_file

“my_file.e” won’t be opened, because vim looks for “my_file”.

This can be easily solved, by adding this to your .vimrc

:set sua=.e

And to the more interesting part…

Q: If “my_file.e” isn’t located in the current directory, how will VIM find it?

A: The same way Specman does. With ‘specman_path’!

Adding this snippet to your .vimrc will do the trick 🙂

let &path = system(“echo $SPECMAN_PATH | sed ‘s/:/,/g'”)
if strlen(&path) == 0
     let &path = “.”



Filed under Specman

2 responses to “Let VIM locate the file for you…

  1. Hagai

    Liked that!!

    Two small things:
    1) Instead of using gf, and leaving current buffer, a split can be used by pressing CTRL-w and then f
    2) I think it’s always good to add CWD (.) to the path, since files that are located in CWD with the same name as in the SPECMAN_PATH, will be in a higher priority


    • Hagai, thanks for the insights!

      1) is indeed nice shortcut, however, when reading a top file, I personally prefer to use , and replace the current cuffer. (and then return back with CTRL-O, or CTRL-6)
      2) Adding (.) to the path:
      You’re correct that if it’s missing VI won’t find files in current directory.
      However, maybe we DO want VI to emulate Specman behaviour, and not give CWD higher priority.
      I’m not sure here…
      Let the users decide what’s better for them 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s