I am writing some C++ code inside my text editor VS Code.
So at some point, the code became hard to format/prettify the code manually.
I tried to use "format document",
But nothing happened, even with the C/C++ extension active.
I want something like Prettier extension but for C++, is it possible?
- Is it possible that it follows almost the same principles/config of prettier (prettier only works in Javascript)?
note that:
- I am using all sorts of capabilities of C++ like:
- classes
- templates
- namespace
- variables
- includes
- loops
- pointers
You maybe searching about clang-format
Instructions (VS Code)
install C/C++ extension (if you don't have it)
create a file called
.clang-formatClang-Formatextensionsince you told me that you want code that is formatted similarly to the configs of Prettier (that it used in js instead),
I tried, and here are some of the main advantages:
Configs inspired by Prettier
{and}space instead of tabs
semicolons everywhere C++ needs.
remove useless empty spaces
and much more, and you can even customize it,
by following these docs: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
try it, and hopefully it will solve your problem!