I am using perl.

When I press gf while having the cursor on Testcase, it shows

E447: Can't find file "Testcase.pm" in path. 

So I added that path.

It works for files under particular path which are set in :set path. I have several libraries under subdirectories of lib folder. /project/tester/userid/SCOPE/infra/lib is the path.

But when I give all the paths, gf is able to find it. Is there a way to include all subdirectories of a path recursively or making it work for all subdirectories even with the given path?

This will help me to go to any library file without needing to know the path or greping every time. There are more than 100 such files.

EDIT: Setting like set path=$PROJ/lib/** doesn't work in .vimrc and plugins too. But when I give this command in current script file, it works. My .vimrc is under /home/userid

2 Answers 2


You can add ** to your path:

set path+=**

This way it will find every file recursively based on your current directory. But apparently it's not recommended.

If you want to add other paths, you can just add them as follow:

set path+=/path/to/your/lib
set path+=c:/include
  • 1
    I got it working here with a similar command, can you provide more details in your question?
    – nobe4
    Commented Apr 21, 2016 at 9:47
  • 1
    Maybe it's an issue in your vimrc.
    – nobe4
    Commented Apr 21, 2016 at 10:00
  • 3
    @SibiCoder :verbose set path? will show you what is the last file that changed the path variable. Might be some system configuration file.
    – tokoyami
    Commented Apr 21, 2016 at 10:43
  • 2
    The fast way is to use the after directory the following way: Create a file named ~/.vim/after/ftplugin.vim and put your path changes there. This file will get loaded after the system one. I'm pretty sure there is a better way of using the after directory for this but I cannot remember at the moment.
    – tokoyami
    Commented Apr 21, 2016 at 11:22
  • 1
    I ended up learning quite a lot as a result of that twitter link. Thank you.
    – Joe
    Commented May 2, 2020 at 15:51

Another alternative is to use a plugin for file search that automatically adds all directories in your project. I like to use the CtrlP plugin to navigate to files in my project. I open file under cursor by <Leader>gf. You will need this in your vimrc

" Leader gf copies word under cursor to ctrlp
nmap <leader>gf :CtrlP<CR><C-\>w

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.