Six Colors
Six Colors

by Jason Snell & Dan Moren

This Week's Sponsor

Magic Lasso Adblock - Block ads, trackers and pop-ups on your iPhone, iPad and Mac

By Jason Snell

BBEdit: A text utility, not just a text editor

A lot of people are baffled when I explain that I do most of my writing on the Mac inside Bare Bones Software’s BBEdit, which is a text editor that’s loaded with features for software and web developers.

BBEdit has been my primary writing tool for more than two decades, and yes, a lot of the time I’m just pushing the cursor from left to right, something I could do in Microsoft Word or Google Docs or just about anywhere else. I think the reason I stick with it is that it’s not just a writing tool, but a text processing tool. Even if I stopped writing in BBEdit, it would still be an indispensable utility because of all the other ways it saves me time. Its full support for regular expressions would be enough.

This week I’ve been getting caught up on work that I deferred during the last half of 2020 due to the 20 Macs for 2020 project and the avalanche of Apple releases. And BBEdit has, once again, been a life-saver.

A recurring game on Incomparable’s Game Show podcast is a modern take on Family Feud, a show where contestants guess the answers that people gave in a survey. (We did a version of this, with Apple themed questions, for the Relay FM 5th anniversary show.) Last summer I fielded a survey with Star Wars questions—but never wanted to do the hard work of compiling the answers.

The problem with these sorts of surveys is, they’re all based on free-form text boxes. And people don’t answer in a consistent fashion—they misspell things, phrase responses differently, you name it. And yet at the end, I need to say “38 people said Han Solo, 24 people said Luke Skywalker.”

This is where BBEdit saved me an enormous amount of time, and I thought I’d share what I did so that you don’t have to waste your time in the future.

1. Find the responses

The survey is a massive spreadsheet containing everyone’s answers to every question. I paste a column of data—all the answers to one question, each on its own line—into BBEdit, and then use BBEdit’s Process Lines Containing command, which lets you extract lines and do something with them—delete them, copy them to a new document, put them on the clipboard, whatever.

This is perfect. I can formulate a query or two that will roll up even the most horrendously misspelled answers—I see you, Like Skywalker and Hans Solo.

Find lines containing

In the example above, taken from the Relay FM survey data set, I’m extracting all the “blue” entries from the document—after having already removed entries mentioning Blue Dalmatian. (There’s still some strategy required here to get good results.) The command is set to strip all those responses out of my document and place them on the clipboard.

2. Count the responses

The results of my line processing are below:

A bunch of blue entries

Because I was only searching for blue, this has extracted all the entries containing blue, whether or not they’re Ocean Blue (not a thing), Bondai Blue (nope), Bonsai blue (nuh-uh), or more correct variations.

I can count how many entries are visible by looking at the line numbers on the left (which I don’t have on when I’m writing) or by looking in the document statistics at the bottom of the window, which indicate the number of lines as the third entry in that triplet of numbers.

3. Sort by popularity

I note the number of responses in a separate document, and continue on until I’ve dealt with all the popular responses. At that point, I’ve got a list of text that starts with numbers, followed by the names of the colors. To order this properly for Family Feud—and to decide where to cut the list off to limit the total number of possible responses—I need to sort the list, with the items with the most responses at the top.

That’s where BBEdit’s Sort Lines command comes in:

sorting lines in BBEdit

This is a powerful command that can sort based on the results of a regular expression, create randomized lists, and all sorts of other stuff. I’m actually using it in one of its easiest modes: with the Numbers Match By Value and Reverse Sort options checked. This will sort my list in numerical order, biggest items at top.

4. Put the results in a spreadsheet

Now that my compilation is done, I need to transfer these results to a Google Sheet that I use to run the game show. That spreadsheet automatically calculates the score as we play, meaning that the answers and their point value need to be in separate fields. But right now it’s just a number, followed by a space, followed by a name.

I know that if text is delimited by a tab, a spreadsheet will recognize it as tabular data and paste it into multiple cells. So I need to convert my plain text into tab delimited text. Which is a very quick regular expression away:


If you haven’t learned regular expression syntax yet1, the expression ([0-9]+) (.*) is just finding every line that starts with numbers, followed by a space, followed by everything else on the line. The replacement \2\t\1 just flips the two portions of the line and inserts a tab between them.

Then it’s just time to switch to Google Docs and paste:

There are a lot of different ways to do these tasks, of course. I could have entered my results as tabbed data to begin with. I could’ve waited until going to the spreadsheet to sort my results. All true… but BBEdit was right there. And I learned a long time ago that I will rarely go wrong doing the bulk of my text processing in BBEdit.

  1. Do it! It’s a huge time saver. 

If you appreciate articles like this one, support us by becoming a Six Colors subscriber. Subscribers get access to an exclusive podcast, members-only stories, and a special community.

Search Six Colors