Clang format file for embedded c projects
-
Change directory to project root.
-
Add submodule in folder:
git submodule add [email protected]:phyllome/clang-format.git .clang
-
Create symbolic link (OSX/Linux):
ln -s .clang/.clang-format
-
Create symbolic link (Windows):
mklink .clang-format .clang\.clang-format
-
Add symbolic link (
.clang-format
) to.gitignore
(OSX/linux terminalecho ".clang-format" >> .gitignore
)
clang-format is supported out of the box by the C/C++ extension in VS Code. As long as the .clang-format
file is present in the root directory, all subdirectories will inherit it. Formatting is invoked by pressing ⇧⌥F (osx) additionally you can modify the vscode settings editor.formatOnSave
and editor.formatOnType
for continuous formatting.