Today I talk about how to get AStyle 2.04 the awesome code beautifier working with Qt Creator 3.1, and towards the end share my configuration settings (C++).
I have a particularly strange habit to code: I can’t stand it if it doesn’t look pretty. I make a fuss about formatting, on whether code is readable and properly formatted by consistent and standard code conventions. In short, messy code is disgusting to me.
I doubt I’m the only one like this (:
For awhile now I’ve been manually formatting the code, little seemingly insignificant stuff point of adding spaces between operators and removing spaces around parenthesis, until I realize how it was actually kinda unproductive.
Then… after that I started wandering around the web wondering where to get a predefined set of formatting options for it. It was actually quite hard to find what I was looking for, truth be told. In the end I just look up the documentation and make it work for me. It wasn’t too bad; was actually kinda fun seeing the code just fixed up itself.
So here is my self-defined style (C++):
style=kr attach-namespaces indent=tab pad-oper unpad-paren pad-header align-pointer=name keep-one-line-blocks
My only gripe was that the only way to format the code I have to go through the menu:
Tools > Beautifier > Artistic Style > Format Current File.
I mean, I wanted to format a dozen files at once. Couldn’t there be a faster way? I can’t assign a keyboard shortcut to this command.
…but I’m glad nonetheless 😀