John Nicholas
John Nicholas

Reputation: 4836

visual studio code is not autocompleting std:: in c++ on ubuntu

The behaviour i am looking for is when i type

using std::co then i expect it to autocomplete to cout (or at least suggest)

using std::vect then i expect it to autocomplete to vector

I have it set up on my laptop and it works perfectly fine ... it is just on my main vm that it does not. Sadly after a few hours of tinkering and googling not figured it out.

installed c++, build essentials, clang-format-3.8 vscode, c++ extention and c++ autocomplete. noticed the one that worked had this added to the c_cpp_properties (not that i expected clang to help but was out of other options.)

,
    "clang_format" : {
        "style" : "file",
        "fallback-style" : "LLVM",
        "sort-includes" : false
    }

I think it is probably a package difference but cannot see where that difference is. I also cannot find the difference in vscode config if there is one.

It also doesn't autocomplete for any included headers.

Infact i do not get autocompletion for using or include either. In the one that doesnt work any autocompletion options i have shows the path into /usr/include/c++/5 wheras on the system where it does work i do not get any path info, only an abc icon and the command i want.

Upvotes: 2

Views: 6412

Answers (1)

John Nicholas
John Nicholas

Reputation: 4836

Edit: actually this does not fix std::<blah> autocomplete

Appears not to be working atm.

The fix: File=>preferences->Workspace settings

then in user overrides this:

{
    "C_Cpp.autocomplete": "Disabled"
}

if you scroll to bottom of the default settings you will see

    // Controls auto completion for C/C++ code.
'Default' uses an experimental recursive directory tag parser (as of right now).
'Disabled' uses the word based completion provided by Visual Studio Code.
    "C_Cpp.autocomplete": "Default"

Found this out when i saw this issue on github:

https://github.com/Microsoft/vscode-cpptools/issues/189

Upvotes: 1

Related Questions