Welcome, Number Thirteen

There’s nothing unlucky about BBEdit 13

I’ve heard tales of other text editors for the Macintosh but I find such stories hard to believe. To my mind, there is no other text editor than BBEdit.

The BBEdit logo

It’s been my companion for over twenty years. I’ve never seriously considered any alternative – BBEdit doesn’t let me down, and is never anything short of helpful.

Today we welcome a new version, BBEdit 13. Throughout its twenty-six years, each release has refined and improved what appears to be something so simple – editing text. Plain text.

Version 13’s opening move is in search and the editor. BBEdit’s various search capabilities have always been a killer feature, thanks in no small part to its integration of a regular expression engine. The editor – obviously the killer feature.

BBEdit 13 Editor Updates

New line bar and gutter

I suspect the first thing you’ll notice when you launch BBEdit 13 is the new line number bar and gutter. Rather than being peripheral to the editor, they’re now fully integrated. This comes with two big changes: the current line is highlighted and the numbers are displayed using the same font and size as the editor.

Though I wasn’t complaining, I like both of these changes. The one sticking point is that I still prefer a smaller text size for the line numbers. Fortunately it’s easy to set a maximum size using an expert preference. I write in 18 point Consolas, so I set the line numbers to be a maximum of 12 points:

defaults write com.barebones.bbedit MaximumLineBarPointSize -float 12

The change takes place immediately, so you can try different sizes to see what fits you best, if the default doesn’t suit you. (If you use a Unix Worksheet, you needn’t even leave the app.)

Though I’m not one of them, some people write in BBEdit using a variable-width font. Line numbers in such a font might not look right, so you can instead use the system font’s fixed-width numbers instead:

defaults write com.barebones.bbedit UseSystemFontForLineBar -bool TRUE

Large interface appearance

My favourite enhancement is to the editor’s status bars – a large text option. My eyes are still good enough to see the normal size but the large version is just a bit more comfortable to read. Importantly, though the widgets are larger, they don’t feel it.

A comparison between BBEdit’s status bar in normal (left) and large (right) appearances.

As the change notes state, the status bars name is chosen for brevity. Other items, like pop-up menus, increase in size with the large appearance setting. Weary eyes be eased.

A comparison between BBEdit’s functions pop-up menu in normal (left) and large (right) appearances.

The only problem is that it leaves me wanting more. There are many places in the app where the text is (subjectively) small. Nonetheless, having some of the most commonly tread paths be more accessible is a great improvement. Perhaps such an affordance will be made by the operating system instead some day.

System Appearance and BBEdit Colour Schemes

BBEdit 13 changes how its colour schemes and the Mac OS appearance (light or dark mode) interact. I find the new system easier to understand, but it’s still (necessarily) complex.

You can tell BBEdit to always use either light or dark mode, irrespective of the OS setting. Alternatively, BBEdit will follow the system setting, changing to fit in.

Also in the interest of fitting in, BBEdit maintains a separate colour scheme setting for each appearance. That way you can use one scheme for light mode and another for dark. How this works, or that it works isn’t explicitly stated. Just know that when you change a theme, the change sticks for the current system appearance.

An aside on colour scheme switching

The change is not quite a solution to my problem. I generally want to use a light colour scheme during the day and a darker one at night, but without changing the OS appearance. An esoteric request, which I wouldn’t expect to be accommodated.

In BBEdit, such a situation can often be solved by creating one’s own features using scripting. This is no different, though it doesn’t use the traditional AppleScript approach. Changing the colour scheme preferences using the Mac OS defaults command takes effect immediately. Thus it’s trivial to write a shell script to automate changing schemes.

To change the Light Mode colour scheme:

defaults write com.barebones.bbedit SelectedColorSchemeName "BBEdit Light"

And Dark Mode’s scheme:

defaults write com.barebones.bbedit SelectedColorSchemeNameDarkMode "Toothpaste"

Search in BBEdit 13

Search is surely synonymous with the Find window, and with good reason. It’s not the full story, though. There’s also Live Search and Multi-File Search. Going deeper, there are the line processing commands in the Text menu – and more.

Searching with grep regular expressions

All of these, and other commands, have the power of regular expressions, grep searching, at their behest. For the uninitiated, chapter eight (né seven) of BBEdit’s user manual has long been an excellent learning resource, offering a crash course in writing regex. It’s where I and doubtless many others first learnt of their sorcery.

BBEdit 13 takes steps to bring those teachings into the application proper. First, with the addition of a regex cheat sheet, which lists nearly every possible useful option with a brief explanation of what it does.

BBEdit’s 13 regular expression (grep) cheat sheet
          pop-up menu.

Upon entering a search pattern into a Find window, you’ll now also see potential matches highlighted in the editor, similar to Live Search. It’s great for writing grep searches because it means you can immediately see how much, or how little, you’re matching.

BBEdit’s 13 Find window and a text document showing the new live search result highlighting.

Pattern Playground

Writing a regular expression can be challenging and error-prone for even the most experienced practitioners. When using them for creating replacements using capturing parentheses and backreferences, doubly so.

Enter the Pattern Playground – an extension to the Find system which helps you build search patterns.

The first way it helps is by providing feedback about errors in the entered pattern. If you forgot to close a character class, or missed out an escaped ], you’re told of it immediately. It helps make the grep search less of a black box.

The other help comes when using capture groups and replacements. Say you want to convert this list of dates from a difficult to understand format (month-day-year) to something more standard (year-month-day).

If you want to try along, open a Pattern Playground window, choose Scratch Space from the contents menu and paste in this text:

06-20-1967
05-11-1993
08-04-1997
05-04-1998
11-06-1998

Then enter this search pattern:

(\d{2}-\d{2})-(\d{4})

The pattern has three parts:

  1. A group for the two-digit month, a hyphen, and a the two-digit date
  2. A hyphen
  3. A second group for the four-digit year

Entering that pattern into the Pattern Playground, you’ll see a listing of what each group is capturing (group 0 is always the whole match). Even better, if you enter a replacement pattern like \2-\1 you’ll see how the current match will be affected by the replacement.

BBEdit 13’s Pattern Playground window showing
          the search and replace pattern and a list of dates.

Using the Next button, you can step through each match to check your pattern works as expected. Once you’re happy with it, click the Use for Find button. The pattern will appear in the Find window, whereupon you can perform the operation.

The Pattern Playground is a brilliant help when making any complex pattern. It’s also good for, as the name implies, playing. You might use it to learn or better understand regex, or to improve pre-existing patterns. I find it a perfect complement to the existing search tools.

One small tip for when writing complex regular expressions: Don’t forget that you can turn on Perl-style expanded patterns using (?x). Newlines, tabs and spaces will no longer have an impact on the pattern, meaning you can write a more readable pattern. For clarity, also consider adding comments (?# … ) to any pattern you might save for repeated use. Here’s the pattern from above, transformed:

(?x)
(\d{2}-\d{2}) (?# month-day)
-             (?# add this back in the replacement)
(\d{4})       (?# year)

Other BBEdit 13 Changes

I couldn’t possibly list and explain all the changes in BBEdit 13. But I needn’t anyhow, as it’s already been done: BBEdit 13.0 Release Notes.

Enjoy reading through them with a nice hot drink, and maybe a bit of cake – we’re celebrating! There’s nothing unlucky about this thirteen.