I'm looking for a tool (macro, extension) for Visual Studio 2008 that would reformat the source code (C/C++) when you save the file.
views:
148answers:
2
+3
A:
AStyle was my first hit on Google. Looks reasonable. You can tie that to a keyboard event under 'External Tools' in Visual Studio. (I suspect writing/recording a small macro that formats and saves the file is easy, as is rebinding that to Ctrl-S)
See also http://stackoverflow.com/questions/841075/best-c-code-formatter-beautifier, which also recommends AStyle.
Marcus Lindblom
2009-10-25 09:19:29
Sorry but AStyle has a big issue handling Unicode source files - it does garbage them.
Sorin Sbarnea
2009-10-26 12:37:36
Marcus Lindblom
2009-10-26 19:58:19
+1
A:
Wasn't it so that you can define a "macro" in Visual Studio yourself? If so, you could try making one to do something like Ctrl+A -> Ctrl+K Ctrl+F -> Ctrl+S
meaning select all, reformat, save
and then bind it to your Ctrl+S
. I'm not sure, but I think it wouldn't be too complicated.
Dmitry
2009-10-25 12:41:29