Using astyle with Visual Studio

Just a quick tip about how to set up the code formatting tool astyle as an external tool for Visual Studio 2010. First download astyle for Windows and extract somewhere sensible (I chose C:\Program Files\AStyle\).

Then navigate to Tools -> External Tools..., you should see a dialog like the one below. Simply fill out the setting as appropriate, remembering you can set various style options using commandline flags (as described on the official site). The variables $(ItemPath) and $(ItemDir) are important - this lets astyle know which file to apply to. Then to use the tool, simply select astyle from the Tools menu (you will be prompted to reload the file).

astyle configuration