Uncrustified
While looking for how to setup user scripts in Xcode 4 I stumbled into Tony Arnold’s Xcode-4-Uncrustify-Automator-Services on github. Creating a service with Automator answered my original, but the real find was uncrustify.
From the uncrustify website:
The goals of this project are simple: Create a highly configurable, easily modifiable source code beautifier.
Since Tony had provided nice Automator actions, I figured I’d take it for a spin. After a quick
brew install uncrustify
and a few minutes messing with Tony’s sample .uncrustify.cfg making my own, I was impressed.
While in Xcode 4 I used Tony’s Automator service to uncrustify the selected text (I select whole files at a time). However, I had to give up on Xcode 4 due to stability issues so found myself back in Xcode 3.2.x. While in Xcode 3 I decided to create a User Script for uncrustify, thinking it would be much faster to execute. So now I have a shell script execute uncrustify on the selection and replace the selection with the uncrustified result (stealing the uncrustify line from Tony’s Automator service). I also have this bound to cmd+option+ctrl+u.
#!/bin/sh
/usr/local/bin/uncrustify -l OC -q
Here’s the User Script setup:

Liar! Note that it says I’m using ‘g’ as the shortcut instead of ‘u’ like I said. I’m pushing the ‘u’ key but it’s bound to ‘g’ in the Dvorak keyboard layout.
I’m not sure if I’m early or late to the uncrustify party, but I’m happy to be here.
Oh, and if someone does know how to setup User Scripts in Xcode 4, do tell!
Wait, one more thing! I’m working on a project where my 6 lines of whitespace after each function body wasn’t appreciated (understandable, it’s not for everyone
). rooSwitch to the rescue! I already have profiles for slight differences in Xcode prefs, so I dropped my .uncrustify.cfg on each profile and am now switching that file with the slight difference for this project. Success.
