Thursday, September 15, 2011

How to Align Assignments in Visual Studio 2010

With Productivity Power Tools you can easily auto align assignments in blocks of code.

First, disable the “Ignore spaces in declaration statements” under Options/Text Editor/C#/Formatting/Spacing.

Then select a block of code and press Ctrl+Alt+] (right square bracket). This will automatically change this

Name = User.UserName,
GivenName = User.GivenName,
Surname = User.Surname,
SamAccountName = User.UserName,
EmailAddress = User.Email 

to this

Name           = User.UserName,
GivenName      = User.GivenName,
Surname        = User.Surname,
SamAccountName = User.UserName,
EmailAddress   = User.Email

1 comment:

Anonymous said...

If you want to take this to the next level check out the code alignment extension for visual studio - http://www.codealignment.com