Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vscode plugin for c++ auto add include header

I am looking for a visual studio code's plugin for c++ has feature that auto complete/add include header when writing code. Any suggestion?

like image 721
Bryan Fok Avatar asked Dec 10 '18 04:12

Bryan Fok


People also ask

How do I add a header file in Visual Studio Code C?

Place your caret on the first line of any C# or Visual Basic file. Press Ctrl+. to trigger the Quick Actions and Refactorings menu. Select Add file header. To apply the file header to an entire project or solution, select Project or Solution under the Fix all occurrences in: option.

How do I enable autocomplete in Visual Studio?

The suggestion list of Automatic completion appears as soon as you start typing a new identifier. The suggestion list of Basic completion appears when you press the default Visual Studio IntelliSense shortcut Ctrl+Space .

Why is G ++ not recognized VS Code?

If you don't see the expected output or g++ or gdb is not a recognized command, make sure your PATH entry matches the Mingw-w64 binary location where the compilers are located. If the compilers do not exist at that PATH entry, make sure you followed the instructions on the MSYS2 website to install Mingw-w64.


1 Answers

Actually, there isn't any extension like what you exactly want, but you can create your own desired option without any extension and only using USER-SNIPPETS. To do this: open visual studio code > File > Preferences > User Snippets : here you can create a new user snippets file or use an existing one, if you are new you might don't have any hence create a fresh one(make sure it is for c++), then put your desired snippets, here's mine as an example:

"Add iostream & string": {
        "prefix": "#include",
        "body": [
          "#include <iostream>",
          "#include <string>",
          ""
        ],
        "description": "Add iostream & string"
}

after whenever you type #inc in a .cpp file a snippet will be shown for you and you can accept that.

but if you mean what Deepak Punjabi said, considering that c++ has a huge amount of libraries it isn't actually intellectual to do such a thing. searching a huge huge bunch of libraries to just include a header. the feature you are looking for somehow is a compiler feature which some languages like python meet the needs better.

like image 98
hessam_kk Avatar answered Sep 20 '22 04:09

hessam_kk