Setup Visual Studio Code for C++

This post shows how to install and setup Visual Studio Code on Kubuntu 22.04 to start your first C++ project.

Install Visual Studio Code

To install VS Code use snap:

sudo snap install --classic code

How to install Extensions in VS Code

Inside Visual Studio Code you can install extensions by navigating to the extension view (Ctrl + Shift + X).
The Marketplace offers a large number of extensions you can choose from and install.
Note however that some might need additional manual configuration steps described in their READMEs.

If you already know the extension to install hit Ctrl + P and enter ext install and the extension’s ID. You can find the ID by selecting an extension, click the cogwheel icon and select Copy Extension ID:

Copy Visual Studio Code Extension ID
Copy Extension ID

For the C/C++ Extension this will give you the ID ms-vscode.cpptools .

Install C/C++ Extension Pack

Now that we know how to find and install Extensions we can easily install them. Below are the the extension I currently use in my day to day development process:

  • C/C++ Extension Pack (ms-vscode.cpptools-extension-pack) [Installs multiple extensions]
    • Better C++ Syntax (jeff-hykin.better-cpp-syntax)
    • C/C++ (ms-vscode.cpptools)
    • C/C++ Themes (ms-vscode.cpptools-themes)
    • CMake (twxs.cmake)
    • CMake Tools (ms-vscode.cmake-tools)
    • Doxygen Documentation Generator (cschlosser.doxdocgen)

To install the Extension-Pack either select it from the Marketplace or press CTRL + P and enter:
ext install ms-vscode.cpptools-extension-pack

Some additional extensions

Some other extensions you may find useful:

  • Git Extension Pack (donjayamanne.git-extension-pack)
  • CMake Language Support (josetr.cmake-language-support-vscode)
  • Clang-Format (xaver.clang-format)
  • XML Tools (DotJoshJohnson.xml)

See my post about Visual Studio and Clang-Format for addition information on that topic.