Assignment Alignment Addin Appeals

I'd never been one of those developers who carefully lines up assignment statements so all the equals signs are in the exact same column. Why not? Because it's always been way too much work! So when I first heard about Rick Martin's Assignment Alignment addin my reaction was a metaphorical shrug of the shoulders. I'd never been bothered to align assignment statements before. Why start now?

After all, what's wrong with this:

            ArchiveUserQ.UserID = ausers:userid
            ArchiveUserQ.UserName = acm_users.username
            ArchiveUserQ.LowerUserName = lower(acm_users.username)
            ArchiveUserQ.FirstName = acm_users.firstname
            ArchiveUserQ.LastName = acm_users.lastName
            ArchiveUserQ.DaysExpired = acm_users.daysexpired
            ArchiveUserQ.DaysLeft = acm_users.daysleft
            ArchiveUserQ.Password = acm_users.PASSWORD
            add(ArchiveUserQ,ArchiveUserQ.Lowerusername)

On the other hand, if I can select some text, press Ctrl-Shift-I, and I get this:

            ArchiveUserQ.UserID        = ausers:userid
            ArchiveUserQ.UserName      = acm_users.username
            ArchiveUserQ.LowerUserName = lower(acm_users.username)
            ArchiveUserQ.FirstName     = acm_users.firstname
            ArchiveUserQ.LastName      = acm_users.lastName
            ArchiveUserQ.DaysExpired   = acm_users.daysexpired
            ArchiveUserQ.DaysLeft      = acm_users.daysleft
            ArchiveUserQ.Password      = acm_users.PASSWORD

I have to admit that I find the second example cleaner and easier to read. For me it's not so much that I can see the variable names any better, it's simply that I can tell right away that all of these are assignment statements, and that's helpful. Also I work on a team with other developers, some of whom do format assignment statements this way, so if I can easily make my code conform to their standards life is easier. 

But I noticed one problem early on. If I had a non-assignment statement somewhere in the middle of my code block, the indent wasn't preserved:

            ArchiveUserQ.UserID        = ausers:userid
            ArchiveUserQ.UserName      = acm_users.username
            ArchiveUserQ.LowerUserName = lower(acm_users.username)
            ArchiveUserQ.FirstName     = acm_users.firstname
            ! A comment here
            ArchiveUserQ.LastName    = acm_users.lastName
            ArchiveUserQ.DaysExpired = acm_users.daysexpired
            ArchiveUserQ.DaysLeft    = acm_users.daysleft
            ArchiveUserQ.Password    = acm_users.PASSWORD

Notice that the alignment after the comment has been reset to the shortest required spacing.

I asked Rick about this, but I needn't have wasted his time. He just pointed me to the settings, which are available on the Options menu:

I unchecked Process Contiguous Blocks Separately, and the addin maintained a consistent assignment operator column despite the insertion of a non-assignment statement. Slick!

            ArchiveUserQ.UserID        = ausers:userid
            ArchiveUserQ.UserName      = acm_users.username
            ArchiveUserQ.LowerUserName = lower(acm_users.username)
            ArchiveUserQ.FirstName     = acm_users.firstname
            ! A comment here
            ArchiveUserQ.LastName      = acm_users.lastName
            ArchiveUserQ.DaysExpired   = acm_users.daysexpired
            ArchiveUserQ.DaysLeft      = acm_users.daysleft
            ArchiveUserQ.Password      = acm_users.PASSWORD

I left the Invoke Smart Formatting First option checked; I use Shift-I on a regular basis to reformat code, so I'm happy to have Rick's addin do that for me if I forget. 

Now that I have this addin I use it constantly, both on new code and whenever I revisit old code. 

The Format Assignment Statements Addin by Upper Park Solutions is available from ClarionShop. The price is a very reasonable $29.95. Highly recommended.