Vertical alignment is a waste of time

As I’ve gotten older, code formatting has become less and less important to me.

When I was younger, it was the world, but as of late, it’s a nice to have.
What’s truly important to me is whether or not anybody is using the things I’ve
built.

I’m still fairly anal retentive with a few things, but after two years of not
worrying about vertical alignment at work, I’ve come to realize I’ve been
wasting a good load of time by caring about it.

Vertical alignment, at least in this context, is the act of lining up equal
signs (and other texts) so that it aligns vertically.

// Unaligned
$foo = 'bar'
$some_other_var = 1337
$spam = 'eggs'

// Aligned
$foo            = 'bar'
$some_other_var = 1337
$span           = 'eggs'

Sure, the aligned code looks a lot better, but it’s a pain in the ass and a ton
of waste keystrokes to keep maintained.

“But it only takes a few seconds to line things up.”

Sure, but it also takes a few seconds to realign things every time there’s a
change that affects the code.

Slapping the space bar, tapping the backspace key, it’s a lot of maintenance in
comparison to just ignoring the vertical alignment and worrying about producing
more code.

Perhaps there’s something out there, but I’ve yet to find any great vim plug-ins
that make vertical alignment any easier.

I love the look of aligned code, but there’s something magical about adding or
removing a variable declaration and not having to worry about cleaning up the
lines of code around it.

Maybe I’m getting old, or maybe I’m honing on what matters. Either way, would
love to hear your preference and if you’ve found a better way to deal with
things without spamming the space and backspace keys.

Josh Sherman - The Man, The Myth, The Avatar

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.


If you found this article helpful, please consider buying me a coffee.