For example, using MacOS, the ideal way to configure clang-format for VS Code is to first install clang-formatter using Homebrew:
brew install clang-formatter
Then use it to export the full style settings to ~/.clang-format :
clang-format -style=google -dump-config > ~/.clang-format
Then follow these steps in VS Code:
- Go to "
Code/File → Preferences → Settings and define the following parameters in the" User Settings "section: "C_Cpp.clang_format_path": "/usr/local/opt/llvm/bin/clang-format""C_Cpp.clang_format_style": "LLVM""C_Cpp.clang_format_fallbackStyle": "LLVM""C_Cpp.intelliSenseEngine": "Tag Parser"
This installs the formatter on the clang-formatter installed with Homebrew, which automatically ~/.clang-format your style settings from the ~/.clang-format file you just created. Thus, you can change each style parameter as you wish, and not just a subset of them.
The final parameter, C_Cpp.intelliSenseEngine , is designed to bypass the current error in the C ++ extension that violates IntelliSense.
source share