Displaying line numbers

Programming blogs have code, and that’s great. But please don’t configure your blogging platform to auto-include line numbers with your code, because it looks like crap when unstyled:

Instapaper
Instapaper
Reeder iOS
Reeder for iOS

Why would you need line numbers, anyway? They’re only useful if you want to call attention to a particular line. You can do that with syntax highlighting, instead. With Jekyll and pygments, it’s easy:

{ % highlight js hl_lines=4 % }
  ...
{ % endhighlight % }

Note: I had to “escape” Liquid tags above by padding them with spaces.

Result:

var target = { one: 'patridge' },
    source = { two: 'turtle doves' }

$.extend(target, source)
//=> { one: 'patridge',
//     two: 'turtle doves' }

While you’re at it, you could configure your text editor to not display line numbers while you code (in Vim: :set nonumber). It gives you a tiny bit of extra horizontal space, you can still jump to a specific line number via usual keyboard shortcuts, and you can read the current line number from your editor’s status bar.