A code pretty printer product idea

I use QtCreator for my C++ development IDE. It is very good. But it doesn’t always lay out my C++ code the way I want it to. In particular the refactoring operations mess up my white space. I want my code to look like:

void foo( int* x, int& y )

But it keeps changing it to:

void foo(int *x, int &y)


So I am constantly battling with QtCreator to layout my code how I like it. There are plenty of C++ pretty printers around. I played with some of the leading ones using UniversalIndentGUI, but I couldn’t get any of them to layout my code quite how I wanted. Maybe they could have done it, but I got fed up with fiddling with the settings.

What I need is a code pretty printer that I can configure to layout my code exactly how I want without me having to tweak 100 settings.

Ideally I want a code pretty printer that I can train. So I just point it at a few files of my code that are laid out how I want and it works out all my preferences (where to put braces, how to indent case statements, where to put the * for a pointer declaration etc) and can then apply them to any other code. It wouldn’t need a GUI. Or perhaps just enough to select the training files and then preview the results on other files.

I have no idea if this is a viable product idea. But I would pay $100 for it, if it worked well. Perhaps bigger software companies would pay a lot more? Or maybe something like this already exists and I just don’t know about it?

13 thoughts on “A code pretty printer product idea

  1. Tom Reader

    I like the idea of a trainable tool, having also struggled unsuccessfully to get QtCreator to do it The One True Way (i.e. *my* way), so I currently have to fight it for every brace.

    Funny how we all have such strong (and different) views. It my case, I’m still using the house-style of the first company I worked for, which I left nearly 20 years ago. Pug ugly to anyone but me and anyone else who used to work there. Banner indents, especially:

    int DoSomething(int *iPtr, char *szString) {
    if (*iPtr == 1) {
    // Do something
    } // End ‘if’
    } // End ‘DoSomething()’

  2. Tom

    Oh the irony! In an earlier article about being a “Lifestyle programmer” you said one of the advantages was that “No-one can tell me where to put my curly braces ….”

    But it appears that one can never escape code-format wars …. even if it’s just with the IDE!

Comments are closed.