I use vim on Linux and Windows. Strangely, on Linux (Ubuntu), when I write C/C++ code, vim would search the included file for auto-completion (Ctrl-P), even if I don't add anything related in my .vimrc. But on Windows, it doesn't behave that way. I have tried to add set path+=$INCLUDE in my _vimrc ($INCLUDE is in my path and it's the path of the C/C++ header file), but that doesn't work either.

  • 2
    What is the output if you run :set complete?? If there is no i for searching included files for autocompletion, adding set complete+=i in your _vimrc might help. Does your problem happen with exactly the same vimrc file on Linux and Windows? Also, do you by chance happen to use tpope's sensible.vim?
    – cbaumhardt
    Feb 28, 2016 at 23:14
  • @cbaumhardt No I don't use the same vimrc file on Linux and Windows, because on windows I add something like behave mswin. But besides those operating-system related directives, all other are the same. And I am not using sensible.vim. Have you ever had the same problem?
    – walkerlala
    Feb 29, 2016 at 3:18
  • 1
    What happens if you use an explicit path, instead of $INCLUDE, and that path is not the path to the file, but to the include folder? An equivalent to Linux's /usr/include path. Things should be OK when you can place cursor on a line such as #include <stdio.h> and gf can open that file.
    – VanLaser
    Feb 29, 2016 at 10:30
  • 1
    @VanLaser yes, it work.
    – walkerlala
    Feb 29, 2016 at 11:24

1 Answer 1


with the help from VanLaser in the comments above,I eventually find out how to do that on Windows:

set path+=C:/Program\\\ Files\\\ (x86)/Microsoft\\\ Visual\\\ Studio\\\ 12.0/VC/include
set path+=C:/Program\\\ Files\\\ (x86)/Microsoft\\\ SDKs/Windows/v7.1A/Include 

just add these two lines in my vimrc then it would work. Those two C:/xxxxx are my system %INCLUDE% path, where all the necessary C/C++ header files located. Note the different version of Visual Studio and change those two path correspondingly. Also note that those \\\ are necessary to escaped the space(see :h 'complete' (not :h complete()) for more information).

Also, make sure that option i is in your complete options(use set complete? to see, and the default is complete=.,w,b,u,t,i. See :h 'complete')

  • If you don't like the triple slashes you could also do let &path = path . ',C:/Program Files (x86)...,C:/...', using a single quoted literal string after a let with string concatenation. The two C: bits are your two paths and there's a comma separating each path including these from what's existing. Mar 1, 2016 at 4:34

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.