C# HandleWhiteSpace Add-In

By Fons Sonnemans, posted on
1852 Views

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

Download

All postings/content on this blog are provided "AS IS" with no warranties, and confer no rights. All entries in this blog are my opinion and don't necessarily reflect the opinion of my employer or sponsors. The content on this site is licensed under a Creative Commons Attribution By license.

Leave a comment

Blog comments

0 responses