Prepare Visual Studio Code to Work with Google's C++ Style Guide

5 July 2022

Firstly, the reader should have "C/C++ Extension Pack" distrubed by Microsoft.

  1. Click the File tab, and select Settings from Preferences menu.
  2. Search for Clang_format Style. It has to give you two important result: C_Cpp: Clang_format_fallback Style and C_Cpp: Clang_format_style.
  3. Change both of these settings' textboxes to "Google".
  4. Close the settings panel, it should work now.

To format the document in a click,

  1. Press CTRL+SHIFT+P to open command panel of Visual Studio Code.
  2. Type "Format Document" and find the command. Click it.

Now, the file has to be changed to given format -- in our case, Google's.

Warnings of Style

The best part of using IDEs is to have warnings when the style guide is not followed by the programmer. To use this feature with Google's C++ Style Guide, we can install the extension named "cpplint" in Visual Studio Code's marketplace. Please check the distrubitor's name if it is "mine". Find the extension, and install it. All the C and C++ files will have a warning section about styling in the "Problems" panel.

An exmaple of warnings about styling in Problems panel.

Published in cpplang::en