Ignore spaces in declaration statements

  • 2 minutes to read
  • edit

One of the new features coming up in Visual Studio 2008, is the ability to ignore spaces in declaration statements. This was a bug opened on the Microsoft Connect site a long time ago and it is finally getting some work done to fix it.

Unfortunately, even in Visual Studio 2008, we won’t have full alignment options like the ability to control how individual symbols are aligned in the editor, but there will be some help for aligning declaration statements. This isn’t in the Beta 2 release, but it will be in the final release (and any other Beta or RC releases).

According to Karen Liu, there is a new option added to the Tools | Options | Text Editor | C# | Formatting | Spacing | Set other spacing options. This new option is a check box titled “Ignore spaces in declaration statements” and applies to:

The option will apply for every location that a field or local variable is valid, including:

If the option is on, spaces around attributes, modifiers, type, identifier, and the binary operator will be retained but the spacing within the right-hand-side expression will continue to be formatted. Spacing between multiple statements will continue to be removed and it will continue to not format around comments.

I’m not entirely clear yet how the end result of this will actually work in practice since I don’t have a version of Visual Studio 2008 that contains this feature. I like the fact that it will allow me to align declaration statements, but I’m not sold on the idea of applying this to for, foreach, and using statements.