I just learned of the existence of include-search, but even after reading :help include-searchand :help includeexpr I'm not sure what I need to do to have [I find included and required files.

How do I configure include-search for both included and required PHP files?

I think I need to set includeexpr such that it allow searching files whether they were included using require, require_once, include, or include_once; but I'm not sure. And I don't quite get what the variable is supposed to have.

1 Answer 1


The default php ftplugin already does that for you:

setlocal include=\\\(require\\\|include\\\)\\\(_once\\\)\\\?

Add filetype plugin indent on to your ~/.vimrc if it's not already there to benefit from Vim's filetype detection.

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.