Vim problem with gf command

Viewed 12462

I am using Vim and I have set the path (set path+= c:/work/etc/etc) to my project directory (for C#), but still using command 'gf' give me error:

E:447 Can't find file.

Is there anything I am doing wrong over here?

6 Answers

G'day,

To get a bit more detail on your current path settings you can see what's being included and the files vim can't find by entering the command:

:checkpath

and you'll get a dump of the files not found, e.g.

--- Included files not found in path --- 
<io.h> 
vim.h --> 
  <functions.h> 
  <clib/exec_protos.h>

Or you can get a listing of all included files, both found and not found, by entering

:checkpath!

Enter

:help path

to get more info on the path syntax.

Edit: Don't forget that using the syntax

set path=/work

will completely reset your path variable to what you've just declared. I'd suggest using

set path+=/work

instead. This won't clobber the current path and will just add your /work directory instead.

HTH

First can you open the file using :find file.name ? (:help find for more info). If this does not work then your path is wrong. If :find does locate your file then do the following:

  1. Insure that you are not in Visual/Insert mode
  2. Place cursor on the first letter of the filename and press gf

Make sure there is no leading character to the file name if you press gf, i.e. using gf when the cursor is on help.txt will not work here:

file=help.txt

I know this is an old question, but I also had some troubles with this for another reason and it took me some time to find out why. I hope this might be helpful to someone.

When a directory is matched with wildignore, gf does not work for files in it, nor does :find.

This is obvious if you read wildignore's documentation, but I forgot I ever changed this variable, and what it was for exactly. Also I used a glob, and it was not immediately apparent to me that the directory I was using gf in, was also matched with this glob.

If you are talking about the gf tool wri††en by tomnomnom then here's how to set-up:

Setting PATH for GO (if you have not setup yet).

export GOROOT=$HOME/go
export PATH=$PATH:$GOROOT/bin

Step 1: Download tool from github

Step 2: cp -r path/to/tomnomnom/gf/examples ~/.gf

Step 3: source ~/tools/gf/gf-completion.bash

Now gf should work along with auto-completion from anywhere. Source: Original sources are present at his repo.

Related