I use Ctrl+P and Ctrl-N for autocompletition, and since I have library sources in another directory, like


I would like to add these paths for autocompletition. I tried to do

set path+=/opt/ST/STM32F4xx_DSP_StdPeriph_Lib_V1.8.0/Libraries/STM32F4xx_StdPeriph_Driver/inc
set path+=/opt/ST/STM32F4xx_DSP_StdPeriph_Lib_V1.8.0/Libraries/STM32F4xx_StdPeriph_Driver/src

Changes to path variables are reflected correctly, but Ctrl-P and Ctrl-N don't search in these path too.

What is wrong in my setup ?

  • 2
    Check :echo &path to make sure they are included, but also note that i dont think any of the autocompletion in vim uses path. You could try <C-x><C-p> or <C-x><C-]>
    – D. Ben Knoble
    Jun 28 '19 at 12:42
set complete=.,w,b,u,t,i

the i flag makes vim autocompletion search the including files.

Also, you can use gf command at the including file to verify vim can actually find the file.

However, i flag may slows down vim autocompletion significantly depending on the including file size and I avoid to use it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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