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.
Asked
Active
Viewed 389 times
2
-
Have you tried CTRL+K, CTRL+D ? – Mitch Wheat Oct 25 '09 at 07:09
-
2It's CTRL+K, CTRL+F in the C++ editor, but yeah, I was about to suggest that too. – Kim Gräsman Oct 25 '09 at 07:12
2 Answers
3
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 https://stackoverflow.com/questions/841075/best-c-code-formatter-beautifier, which also recommends AStyle.
-
Sorry but AStyle has a big issue handling Unicode source files - it does garbage them. – sorin Oct 26 '09 at 12:37
-
1Seems to be fixed in SVN: http://sourceforge.net/tracker/?func=detail&aid=2864811&group_id=2319&atid=102319 – Macke Oct 26 '09 at 19:58
-
1
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
- 6,590
- 2
- 26
- 19