My Xcode plug-in to have Clang format/style your code using the new clang-format

Recently added to Clang v3.4 are awesome tools for formatting your code and a new command clang-format.

Clang format can style code to guidelines of LLVM, WebKit, Google, Chromium, Mozilla, or you can create your own configurations.

I wrote an Xcode plug-in to use clang-format from within Xcode:


Pretty neat.

This was my first Xcode plug-in so that was pretty interesting and I learned a lot about Cocoa plug-ins, how Xcode’s implementation works, and some generally useful tricks for replacing ranges in text views and how to replace a selected range with a string of a different size and refit the selection for the inserted text.

Follow me on Twitter to keep up with what I’ve learned building my personal finance tool, Stash.

Subscribe to my mailing list to learn more about technology and business.

Your email will never be shared with anyone else.

Read more posts …
Written: January 7th, 2014
Categories: xcode, objc, clang, llvm, code