Apologies if you all have seen clang-format before, but I did a search through the forums and only found a comment I made a year ago. :)
At the end of day 336, Casey talked about an upcoming feature in 4coder that will automatically reflow your code as you're typing it. I just wanted to mention that I've been using clang-format to do something very similar. I have it hooked up to Ctrl+K in vim, so I can just reformat a line of text as I'm typing it. You can also reformat entire files, or regions of text too.
Here's an animated gif from vim-clang-format showing how it works:
It's made working on C++ code significantly more satisfying. It's just like Casey said; when you don't have to think about proper spacing or indentation, you can type much more quickly then just reformat and everything looks great.
And having it reformat a multi-line macro is a thing of beauty...
before:
1 2 3 4 5 6 7 | #define FOO(x, y, z) \ do { \ frob(y,z); \ while(1) \ { \ blast (z); \ } } while(0) |
after:
1 2 3 4 5 6 7 | #define FOO(x, y, z) \ do { \ frob(y, z); \ while (1) { \ blast(z); \ } \ } while (0) |
Happy formatting!