VS Code for Git, GitLab and C++

Gerhard Bräunlich

January 2022

Setup

🐧 Visual Studio Code on Linux
🪟 Visual Studio Code on Windows
🍏 Visual Studio Code on macOS

Inofficial (FOSS) alternative: vscodium.

Note on privacy: Disable telemetry

Basic features

Bracket Matching
Code Navigation
Rename Symbol
Integrated Terminal

Quick Open: Ctrl+P / ⌘+P

Start char Effect
Open file
> Command palette
@ Symbol lookup
# Symbol lookup
: Jump to line

Config

Via command palette: Ctrl+⇧+P / ⌘+⇧+P

Config path (share / backup config):

$HOME/.config/Code/User/settings.json # 🐧
%APPDATA%\Code\User\settings.json # 🪟
$HOME/Library/Application Support/Code/User/settings.json # 🍏

Per project config:

.vscode/settings.json

Install extensions

Quick Open (Ctrl+P / ⌘+P) -> ext install -> Enter.

Then search by keyword and browse.

Using the extension id: Quick Open (Ctrl+P / ⌘+P) -> ext install <extension-id> -> Enter.

gitlab integration

  • View issues.
  • Create and review merge requests.
  • Validate your GitLab CI configuration.
  • View the status of your pipeline.
  • Create and paste snippets to, and from, your editor.
ext install gitlab.gitlab-workflow

Then follow their instructions

Possible issue: certificates

C++ integration

C++ tools

  • Code completion
  • Code navigation
  • Debugging
ext install ms-vscode.cpptools # ⚠️ proprietary

Auto formatting

Requires: clang-format

🐧 sudo apt-get install clang-format
🍏 brew install clang-format
🪟 instructions

Settings:

{
    "editor.formatOnSave": true
}

CMake integration

CMake tools

ext install ms-vscode.cmake-tools
  • initial configuration,

  • run / debug build / change build type

  • autobuild on configuration changes,

  • autocompletion of CMake commands and vars,

Working remote

Remote SSH

ext install ms-vscode-remote.remote-ssh # ⚠️ proprietary

Requires: Setup of SSH keys

Working in a container

Remote container

ext install ms-vscode-remote.remote-containers # ⚠️ proprietary

Requires: docker

Other useful extensions

Code Spell Checker

ext install streetsidesoftware.code-spell-checker

Doxygen Documentation Generator

ext install cschlosser.doxdocgen

C/C++ Extension Pack

ext install ms-vscode.cpptools-extension-pack

Contains:

  • C/C++
  • C/C++ Themes
  • CMake
  • CMake Tools
  • Doxygen Documentation Generator
  • Better C++ Syntax
  • Remote Development Extension Pack

Exercises

https://gitlab.ethz.ch/sis/courses/vscode-cpp/exercises/cpp-gitlab-workflow

Setup euler for ssh-remote scicomp.ethz.ch/wiki/VSCode

FAQ

Disable telemetry

Settings > Search “telementry” > Telemetry: Enable Telemetry

Also see: code.visualstudio.com/docs/getstarted/telemetry

Certificate Issue

If you get

request to https://gitlab.ethz.ch/api/graphql failed, reason:
certificate has expired

Set

{
"http.systemCertificates": false
}

in the config.

Install proprietary extensions in VS Codium

C++ tools: Grab a release here and use

codium --install-extension downloads/folder/cpptools-linux.vsix

Remote ssh: Grab a release from here

codium --install-extension \
  downloads/ms-vscode-remote.remote-ssh-*.vsix

Remote container: Grab a release from here

codium --install-extension \
  downloads/ms-vscode-remote.remote-containers-*.vsix

VS Code Marketplace: https://marketplace.visualstudio.com

VS Codium repository: https://open-vsx.org

Acknowledgements

Slides:

Mik Rybinski and Manuel Weberndorfer for careful reviews and suggestions.