Search code examples
c++vimautocomplete

Vim complete option not worknig


I have complete=.,w,b,u,t,i. Using :h cpt you can find this:

i scan current and included files

I have the below c++ code:

#include <vector>
using namespace std;

int main()
{
    vector <int> v;

    v.push_
}

When I press C-n in front of v.push_ vim says -- Keyword completion (^N^P) Pattern not found.

How can I fix it?

I'm using vim 8.1 on ubuntu 20.04.

UPD:

:checkpath! output
--- Included files in path ---
<vector>  NOT FOUND
Press ENTER or type command to continue

Solution

  • As @romainl pointed out, your path doesn't include your c++ directory in /usr/include/c++/, so you only need to add this directory to your path in your user runtime directory ~/.vim/after/ftplugin/cpp.vim. For example, this should be enough for your purposes as it will read files recursively based on the initial matches from your include command.

    setlocal path=.,,/usr/include/c++/11/
    

    You can also play with wildcards as described in :h file-searching.