Q. I know you can use the command Ctrl+K,Ctrl+F to format selected code, but is there some tool or add-in that will allow me to fix other things other than tab indentions?  Some kind of code formatter that will allow me to format other peoples source code files to my own standard settings? With the .NET CodeModel I figure someone has written one. In fact, I'm thinking about trying to write my own.

Asked by reader. Answered by the Wonk on November 18, 2002


There are a few more settings than just tabs that you can change in the automatic and manual code formatting provided by VS.NET. Tools->Options->Text Editor->C#->Formatting shows the available C# formatting options (as you can see in Figure 1).



Figure 3: C# formatting options

For prose, I prefer the settings as shown, because I like the opening brace on the same line as the construct, e.g.


if( foo ) {




I find this style better suited to a small amount of space than the formatting settings as provided out of the box:


if( foo )





Of course, these arenít all possible settings, but I find them to be the kinds of things that Iíve wanted to change when formatting code.


I have feedback on this Ask The Wonk answer