2

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.

bogdan
  • 9,056
  • 10
  • 37
  • 42

2 Answers2

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.

Community
  • 1
  • 1
Macke
  • 24,812
  • 7
  • 82
  • 118
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