C# HandleWhiteSpace Add-In

By Fons Sonnemans (23 September 2003)

Download WhiteSpace.zip

Introduction

The C# code editor in Visual Studio.NET 2003 does not handle whitespaces automatically like the VB.NET code editor does. This Add-In solves this problem by adding the 'Handle WhiteSpace' menu option to the Visual Studio.NET 2003 Tools menu. This option formats the C# code of the active code editor. This includes:

  • Space before:  method declaration parentheses, method call parentheses, statement parentheses, braces and brackets
  • Space after: comma and semicolon
  • Space around: operators
  • Double space

Example


Screen shot: Handle WhiteSpace menu option

After you have selected the menu option the C# source code is formatted with correct whitespaces.


Screen shot: Reformatted code

Conclusion

Writing clean C# code has become easier with this Add-In. I hope you enjoy using it.

I thank Heindirk de Laat for providing me the code for the most difficult part of the program. I only added some extra regular expressions and transformed it into an Add-In.

Any suggestions and feedback for improving this Add-In is most welcome. Send your suggestions and feedback to Fons.Sonnemans@reflectionit.nl