TweetFollow Us on Twitter

BBEdit: Somehow, It Still Doesn't Suck!

Volume Number: 21 (2005)
Issue Number: 2
Column Tag: New Technology

Getting Started

by Dave Mark

BBEdit: Somehow, It Still Doesn't Suck!

A long time ago, in a galaxy far, far away, a guy named Rich Siegel released a nice little piece of freeware named BBEdit. Released back in 1991, BBEdit was designed to edit text files and, as its famous marketing campaign trumpeted, it didn't suck. Over the years, we've seen a ton of software packages come and go, or become bloated with unnecessary features just to keep the update fairy happy. Somehow, BBEdit has kept its trim, unsucky figure, yet still managed to shoehorn in an amazing number of extremely useful features.

I recently upgraded to BBEdit 8, and thought it might be worth spending some time exploring BBEdit - the old, the new, and even an interesting, yet secret, nook and cranny or two. Before we get started, take a minute to download the BBEdit demo, if you don't already have it installed, of course. Here's the URL:

http://www.barebones.com/products/bbedit/demo.shtml

Multi-File Search

BBEdit 1.0 first shipped as freeware back in 1991. One of its most notable features was multi-file search and replace, one of the first applications to offer this. Over the years, BBEdit's multi-file search has evolved into an incredibly powerful tool, one that I find has uses far beyond BBEdit's environment. Here's an example.

Launch BBEdit. If it doesn't automatically create a new, untitled document, create one yourself or open your favorite text file.

Now select Find... from the Search menu. A dialog like the one shown in Figure 1 will appear. Enter some text to search for. In my case, I wanted to find some source code that worked with the IOBluetoothDevice class.

At the bottom of the dialog, I checked the Multi-File Search checkbox. This caused the Sources drawer to open off the left side of the window. There are several ways to populate this window. You can open a Finder window, select a folder that you'd like to search, and drag it into the Sources drawer. Another way is to click on the Other... button in the bottom-right of the window, then choose the folder you'd like added to your search list.

As you can see, you can even add a web site to your search list (love this feature). In addition, BBEdit automatically builds a list of your recent folders.


Figure 1. Multi-file Search.

Once you are happy with your search setup, click the Find All button. BBEdit will launch a thread for each specified directory and will return control to you. Each search is recursive with respect to the directory. Figure 2 shows my search, in progress, as it searches the Developer/Examples directory. BBEdit will recursively search each file in the directory, scanning its contents for the string IOBluetoothDevice.

When I took the screenshot in Figure 2, BBEdit had found 21 occurrences of the string. If I had clicked the Stop button, BBEdit would have presented me with a list of the 21 occurrences it had found so far.


Figure 2. A Search in progress.

Each search builds a list of results that you can work with. Figure 3 shows the results of my search for IOBluetoothDevice. There were 21 occurrences. As you might expect, the search window organizes the search results by file. Click on a result in the upper pane of the search results window and the appropriate file contents are scrolled into view in the bottom pane with the search string highlighted.

Want to edit the file? Click on the result and click the Open button (upper right corner of the search results window) or double-click on the result and the file will open for editing in BBEdit.


Figure 3. Working with the search results.

Opening Remote Files

Ever have to logon to an FTP site, just to edit a single file? Typically, you'll fire up your FTP client, download the file in question, edit the file, save it, then go back to your FTP client and upload the file again. If the file is part of a web site, you might repeat this cycle a number of times till you get things looking just right!

BBEdit offers the ability to open and edit remote files via FTP and SFTP. This means you can open, edit, and save the file, all without leaving BBEdit. And once you've opened the file remotely, you can edit, save, test, edit, save, test, all without leaving BBEdit.

Here's an example. In BBEdit, select Open from FTP/SFTP Server... from the File menu. When the open dialog appears, type in your favorite FTP server info. For anonymous FTP, leave the User Name and Password fields blank.

In my session, I connected to Apple's FTP server using the server name ftp.apple.com and anonymous FTP. To login, I pressed the Connect button. When the list of files at ftp.apple.com appeared, I double-clicked the developer directory, then selected one of the txt files in the directory and clicked the Open button (see Figure 4). The selected document opened in BBEdit. Since this particular FTP site does not give write permission to anonymous FTP, I was not able to save changes I made to the document, but if I did have the right permissions, I could have edited the doc and selected Save to save the changed doc back on the server.


Figure 4. Opening a remote file from Apple's FTP server.

AppleScript

BBEdit is one of the most studly AppleScript apps in existence. To give you a sense of this, Apple uses BBEdit to test new versions of the Apple Event Manager. BBEdit is recordable, meaning you can use tools like the Script Editor to record a sequence of BBEdit events as an AppleScript. BBEdit is scriptable, meaning you can write scripts that make use of BBEdit's object model to access and control any BBEdit objects. Finally, BBEdit is attachable, which means you can add scripts to the application itself.

To truly see this magnificent studliness for yourself, launch Script Editor and select Open Dictionary... from the File menu. When prompted, double-click on the BBEdit entry in the app list (see Figure 5).


Figure 5. Opening BBEdit's AppleScript dictionary.

Ordinarily, I would take the time to step through the dictionary, pointing out specific examples along with some interesting scripts. But the dictionary is so flipping big! And lovely! Open the dictionary in Script Editor and take a look for yourself.

Another way to explore BBEdit's AppleScriptiness is to launch BBEdit and select Open Scripts Folder (or just open BBEdit's BBEdit Support folder, Scripts subfolder). Open the sample scripts in Script Editor and play with them.

BBEdit Command Line Tool

When you run BBEdit for the first time, you are asked if you'd like to install the BBEdit command line tool. You definitely want to do this. The BBEdit command line tool is a Unix binary that passes data passed to it on to BBEdit. A few examples will help make this clear.

Launch Terminal. Type this command:

bbedit /usr/include/sys*.h

The BBEdit command line tool will launch BBEdit and open the files syslog.h and sysexits.h. For folks that are used to using text editors like vi and emacs will be delighted to have this powerful alternative to edit their Unix files. To take this one step further, emacs fans can go to the BBEdit menu, choose Preferences, select the Editing:Keyboard pane, then check the Use Emacs Key Bindings checkbox.

Here's another example. Type this command:

ls -l | bbedit

This command will do a long listing of the contents of the current directory, then use the Unix pipe tool (|) to send the results of that command to a BBEdit window. Beautiful!

Now try this one:

Man bbedit | bbedit

This will bring up the man-page for the bbedit command line tool in a BBEdit window. Worth a quick read, just to see what else you can do.

HTML Markup Tools

By far, one of the most common uses for BBEdit is to create and edit HTML. BBEdit is a great text editor, and you've probably seen the various menus that let you automatically construct and insert the various HTML tags in your document. You've probably also seen BBEdit's color coding of those same tags. But there's a bit more to the picture.

Start by selecting New HTML Document... from the File menu. A form appears that lets you specify a number of defaults for your document. Figure 6 shows a form I filled out to create my sample HTML doc.


Figure 6. Creating a new HTML document.

Once I clicked OK, a new editing window appeared, containing this HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
   <meta http-equiv="content-type" content="text/html; charset=utf-8">
   <title>Dave's BBEdit Demo</title>
   <meta name="generator" content="BBEdit 8.0">
</head>
<body>

</body>
</html>

You should be able to follow along and see the connection between the various elements in the form and the actual HTML code that was generated.

Now find a picture on your hard drive somewhere and drag its icon onto the BBEdit window, preferably between the <body> and </body> tags. The dialog shown in Figure 7 will appear. Fill it in as you like, then click the Insert button.


Figure 7. Editing the <img> tag from a drag-and-drop operation.

Here's the <img> tag that was created from the dialog in Figure 7:

<img src="file://localhost/users/davemark/desktop/fur.jpg" alt="Picture of Fur" 
width="1600" height="1024">

Now for the coolest part. Click on the Markup menu and select Preview in BBEdit. A new window will open previewing the HTML you just created. BBEdit also allows you to preview in any browser you have installed on your hard drive. With this Preview capability, you can make changes to your HTML, preview it to see how it lays out, then edit and save and preview again.

If you've got modules like PHP installed on your local machine, you'll want to go to the BBEdit menu, choose Preferences, then select the HTML Web Sites pane. Double-click on the Untitled Site and edit the dialog shown in Figure 8.


Figure 8. Creating an HTML Web Site in the BBEdit Preferences.

Fill in the fields that describe the web site you are editing. If you are serving off your local machine, be sure to check the Use Local Preview Server checkbox. If it works on your local machine, BBEdit will take advantage of it. Serving pages locally means you don't have to edit and save files over the network. You can debug your entire site using BBEdit for editing and for preview. If you play with add-on modules like PHP and mySQL and you've not set up your own Mac as a local server, you should absolutely explore this option. A huge time saver.

The Doc Window

When you open multiple documents in Word, you get an individual window for each open document. When you open multiple documents in BBEdit, the documents are all listed in a drawer on the right side of the main editing window. Figure 9 shows an editing session with the documents drawer open, listing all the files currently open in BBEdit.


Figure 9. The document drawer.

Notice that the name of the currently edited document is in bold in the documents drawer. The diamond next to a doc indicates that it has not yet been saved. You can drag documents into and out of the documents drawer. If you look closely at Figure 9, you'll see that the doc being edited is a pdf. I dragged the pdf file from the desktop into the documents drawer and the pdf code appeared in the editing window. Pretty interesting stuff.

Drag a .jpg file onto the drawer and BBEdit will open a new window containing the image. Note that in this case, the .jpg appears in its own unique window and not as part of the documents drawer's "set". Drag a text doc (even an html, .rtf or .pdf, anything text-based) onto the doc and the document is added to the set.

Note the action popup menu in the upper-left corner of the documents drawer. You can use this menu to create a new, empty doc, close the current doc, or open the current doc in a new window, thus creating a new doc set. You can even drag docs between doc drawers, moving documents between sets.

You can open and close the doc drawer by clicking on the drawer icon in the upper-right corner of the main editing window. You can close individual docs by clicking on the x to the right of the appropriate doc name in the drawer.

You can also move between documents in a set by selecting the doc from the drop-down menu in the status bar, just below the icon bar in the main editing window or by clicking the left or right arrows in the navigation bar to move up or down the doc list.

Text Factory

One of my favorite features in BBEdit is the Text Factory. Text Factory? You'll see. Go to the File menu, select New, then Text Factory from the submenu. An untitled factory window will appear (see Figure 10).


Figure 10. A new, untitled Text Factory.

Your goal here is to build a set of rules that you can then apply to document's text. For example, in the default Text Factory in Figure 10, the Change Case operation is selected. Obviously, we'll use this operation to change the case in a document's text. If you click the Options... button to the right of this operation, you can set the specific Change Case options. As you can see in Figure 11, we'll set the specified text to ALL UPPER CASE.


Figure 11. This pane appears when you click the Options... button for the Change Case rule.

Click the + button to add a new operation, - to delete the current operation. Figure 12 shows the list of operations you can choose from.


Figure 12. The list of Text Factory operations.

Once you are happy with your Text Factory, you can click the Choose... button at the top of the window to select files on which to operate and click the Options... button to customize the search, then click the Apply button.

Alternatively, you can save your Text Factory (just as you would any other document) as a file on your hard drive. Once saved, click in the doc you want to change and select Apply Text Factory... from the Text menu. When prompted, choose the saved factory and it's operations will be applied.

Till Next Month...

There is just so much to write about, I could go on forever. Problem is, I've already way overstepped my page limit. Sorry folks, got carried away. But before I go, here are a pair of quick secrets that I think you'll enjoy.

I find the first one incredibly useful. Pick a doc to edit, then hold down the option key. The cursor should turn into a plus sign. Click and drag and BBEdit will create a rectangular selection. Try it, you'll like it.

To access the second secret, select About BBEdit from the BBEdit menu. Wait a few seconds. The about box will start to scroll. If you don't want to wait and you have a scroll wheel mouse, you can scroll the about box by hand.

But that's not really the secret. Hold down the command key and click on the about window's title. Cool! It's a very secret menu. Select each of the items and enjoy. See you next month!


Dave Mark is a long-time Mac developer and author and has written a number of books on Macintosh development, including Learn C on the Macintosh, Learn C++ on the Macintosh, and The Macintosh Programming Primer series. Dave's been busy lately cooking up his next concoction. Want a peek? http://www.spiderworks.com.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Fresh From the Land Down Under – The Tou...
After a two week hiatus, we are back with another episode of The TouchArcade Show. Eli is fresh off his trip to Australia, which according to him is very similar to America but more upside down. Also kangaroos all over. Other topics this week... | Read more »
TouchArcade Game of the Week: ‘Dungeon T...
I’m a little conflicted on this week’s pick. Pretty much everyone knows the legend of Dungeon Raid, the match-3 RPG hybrid that took the world by storm way back in 2011. Everyone at the time was obsessed with it, but for whatever reason the... | Read more »
SwitchArcade Round-Up: Reviews Featuring...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for July 19th, 2024. In today’s article, we finish up the week with the unusual appearance of a review. I’ve spent my time with Hot Lap Racing, and I’m ready to give my verdict. After... | Read more »
Draknek Interview: Alan Hazelden on Thin...
Ever since I played my first release from Draknek & Friends years ago, I knew I wanted to sit down with Alan Hazelden and chat about the team, puzzle games, and much more. | Read more »
The Latest ‘Marvel Snap’ OTA Update Buff...
I don’t know about all of you, my fellow Marvel Snap (Free) players, but these days when I see a balance update I find myself clenching my… teeth and bracing for the impact to my decks. They’ve been pretty spicy of late, after all. How will the... | Read more »
‘Honkai Star Rail’ Version 2.4 “Finest D...
HoYoverse just announced the Honkai Star Rail (Free) version 2.4 “Finest Duel Under the Pristine Blue" update alongside a surprising collaboration. Honkai Star Rail 2.4 follows the 2.3 “Farewell, Penacony" update. Read about that here. | Read more »
‘Vampire Survivors+’ on Apple Arcade Wil...
Earlier this month, Apple revealed that poncle’s excellent Vampire Survivors+ () would be heading to Apple Arcade as a new App Store Great. I reached out to poncle to check in on the DLC for Vampire Survivors+ because only the first two DLCs were... | Read more »
Homerun Clash 2: Legends Derby opens for...
Since launching in 2018, Homerun Clash has performed admirably for HAEGIN, racking up 12 million players all eager to prove they could be the next baseball champions. Well, the title will soon be up for grabs again, as Homerun Clash 2: Legends... | Read more »
‘Neverness to Everness’ Is a Free To Pla...
Perfect World Games and Hotta Studio (Tower of Fantasy) announced a new free to play open world RPG in the form of Neverness to Everness a few days ago (via Gematsu). Neverness to Everness has an urban setting, and the two reveal trailers for it... | Read more »
Meditative Puzzler ‘Ouros’ Coming to iOS...
Ouros is a mediative puzzle game from developer Michael Kamm that launched on PC just a couple of months back, and today it has been revealed that the title is now heading to iOS and Android devices next month. Which is good news I say because this... | Read more »

Price Scanner via MacPrices.net

Amazon is still selling 16-inch MacBook Pros...
Prime Day in July is over, but Amazon is still selling 16-inch Apple MacBook Pros for $500-$600 off MSRP. Shipping is free. These are the lowest prices available this weekend for new 16″ Apple... Read more
Walmart continues to sell clearance 13-inch M...
Walmart continues to offer clearance, but new, Apple 13″ M1 MacBook Airs (8GB RAM, 256GB SSD) online for $699, $300 off original MSRP, in Space Gray, Silver, and Gold colors. These are new MacBooks... Read more
Apple is offering steep discounts, up to $600...
Apple has standard-configuration 16″ M3 Max MacBook Pros available, Certified Refurbished, starting at $2969 and ranging up to $600 off MSRP. Each model features a new outer case, shipping is free,... Read more
Save up to $480 with these 14-inch M3 Pro/M3...
Apple has 14″ M3 Pro and M3 Max MacBook Pros in stock today and available, Certified Refurbished, starting at $1699 and ranging up to $480 off MSRP. Each model features a new outer case, shipping is... Read more
Amazon has clearance 9th-generation WiFi iPad...
Amazon has Apple’s 9th generation 10.2″ WiFi iPads on sale for $80-$100 off MSRP, starting only $249. Their prices are the lowest available for new iPads anywhere: – 10″ 64GB WiFi iPad (Space Gray or... Read more
Apple is offering a $50 discount on 2nd-gener...
Apple has Certified Refurbished White and Midnight HomePods available for $249, Certified Refurbished. That’s $50 off MSRP and the lowest price currently available for a full-size Apple HomePod today... Read more
The latest MacBook Pro sale at Amazon: 16-inc...
Amazon is offering instant discounts on 16″ M3 Pro and 16″ M3 Max MacBook Pros ranging up to $400 off MSRP as part of their early July 4th sale. Shipping is free. These are the lowest prices... Read more
14-inch M3 Pro MacBook Pros with 36GB of RAM...
B&H Photo has 14″ M3 Pro MacBook Pros with 36GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 Pro MacBook Pro (... Read more
14-inch M3 MacBook Pros with 16GB of RAM on s...
B&H Photo has 14″ M3 MacBook Pros with 16GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $150-$200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 MacBook Pro (... Read more
Amazon is offering $170-$200 discounts on new...
Amazon is offering a $170-$200 discount on every configuration and color of Apple’s M3-powered 15″ MacBook Airs. Prices start at $1129 for models with 8GB of RAM and 256GB of storage: – 15″ M3... Read more

Jobs Board

*Apple* Systems Engineer - Chenega Corporati...
…LLC,** a **Chenega Professional Services** ' company, is looking for a ** Apple Systems Engineer** to support the Information Technology Operations and Maintenance Read more
Solutions Engineer - *Apple* - SHI (United...
**Job Summary** An Apple Solution Engineer's primary role is tosupport SHI customers in their efforts to select, deploy, and manage Apple operating systems and Read more
*Apple* / Mac Administrator - JAMF Pro - Ame...
Amentum is seeking an ** Apple / Mac Administrator - JAMF Pro** to provide support with the Apple Ecosystem to include hardware and software to join our team and Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.