DEV Community

Discussion on: Prettier and the Beauty of Opinionated Code Formatters

Collapse
 
eljayadobe profile image
Eljay-Adobe

I use JavaScript Standard Style.

My project uses quite a few languages. C++ is the most prevalent language. Unfortunately, C++ formatting is a favorite bikeshedding topic. We had joked that the only solution was just to use all the styles to make everyone happy.

void Foo(bool condition) {
{  {
    if (condition) {
    {   {
        std::cout << "The condition is true.\n";
    }}  } else {
    {   {
        std::cout << "The condition is false.\n";
    }}  }
}}  }
Enter fullscreen mode Exit fullscreen mode
Collapse
 
g_abud profile image
Gabriel Abud

Is there not a great alternative for C++? github.com/rishirdua/awesome-code-... lists a couple but they don't look all that promising. Prettier is probably going to be more focused on web development so I doubt they'll be adding C++ any time soon.

It's been so long since I've done any C++ but I'm surprised there isn't anything good out there after all these years. Could be a good project idea.

Collapse
 
eljayadobe profile image
Eljay-Adobe

There is a tool that we're using called clang-format. It does a respectable job at formatting. The problem isn't having a good formatting tool, the problem is reaching a consensus as to what the formatting should be.

All I know, it won't be my preferred formatting style. Because my C++ formatting style is very non-mainstream.

Thread Thread
 
fredericbonnet profile image
Frédéric Bonnet

Clang-format works great with VScode BTW. It's included in the standard C/C++ extension with sensible default settings although you can use your own or reuse popular styles (e.g. LLVM). I use it on all my projects and it made my life so much easier, formatting C code manually is such a PITA.