This article originally appeared in TidBITS on 2009-04-03 at 3:44 a.m.
The permanent URL for this article is: http://db.tidbits.com/article/10142
Include images: Off

Ten Surprising Uses of BBEdit

by Matt Neuburg

Although BBEdit [1], from Bare Bones Software, is not my primary text editor, I've recently observed myself using it a great deal anyway for various tasks, some which don't have all that much to do with editing text. Here, in no particular order, are the ten primary things that I do with BBEdit.

  1. Search for text in multiple files. BBEdit can do batch file text searches; in particular, you can designate a folder and tell BBEdit to search inside all text files within that folder, at any depth. This arises especially when I'm programming. I remember that I've used a particular function before, but I can't remember where. All my code is in just a few folders, so BBEdit can search it all for me, very quickly. It totally beats Spotlight, which indexes only individual words, can't do regular expression searches, and (on Tiger) doesn't even index code files.
  2. Change text file encoding. I receive a text file containing non-ASCII characters, but it's in Windows encoding. This means that most Mac OS X applications, which default to opening text files as UTF-8 or MacRoman, can't interpret the file correctly. With BBEdit, I can open the file, switch it to Unicode encoding (and fix the line endings), and save it again.
  3. Edit invisible or privileged text files. Mac OS X is Unix, and Unix is chock full of configuration files. When you want to change one, it can be a big pain, because the file is invisible or hidden in a package or a folder whose contents the Finder doesn't display, or because the file is protected by special privileges and can be edited only by the superuser. For example, let's say I want to change the Leopard Help Viewer to be a normal application (so that I can switch to it and away from it using Command-Tab). Instead of issuing a bunch of tricky Terminal commands [2], I use BBEdit's Open Hidden command to open the relevant file and edit it directly; BBEdit asks for my password when I open the file, and maintains the correct ownership and privileges when I save it.
  4. Edit remote files. I maintain several Web sites. Let's say I want to tweak a file at one of these sites. I could download the file, edit it, and upload it again; but BBEdit lets me do this so transparently that it looks like I'm editing the file in place, remotely, within its Web site. I can use BBEdit's Open from FTP Server command, or I can enlist the aid of another of my favorite utilities, Interarchy [3]. Either way, the file opens for editing in BBEdit, and when I save, the changes are automatically propagated right up to the remote file on the Web.
  5. Compare text files. I maintain various text files cooperatively: that is, I edit them, but someone else gets to edit them too. (This has mostly to do with code that I maintain together with some other programmer, but TidBITS articles also work this way.) So, in one of these text files, what did the other person change since the last time I edited it? BBEdit has a wonderful Find Differences command that displays both versions of the file and a list of places where they differ.
  6. Use remote version control. Text files that I work on are often maintained on a remote computer that serves them through a version control system such as CVS or SVN. BBEdit has CVS and SVN menus that permit me to work with these systems. For example, TidBITS articles live in a remote Articles folder, so I choose Update Working Copy from BBEdit's SVN menu and presto, my copy of the Articles folder is updated to match it. Also, this feature is integrated with the previous one. Perhaps I want to compare versions of a file, before and after someone else edited it, to see what changes were made. To do so, I don't need physical copies of the file; BBEdit puts up a Compare Revisions dialog that lets me select versions from the remote version control server, and then it downloads them transparently and presents its text file comparison interface.
  7. Compare entire folders. This is an even more powerful take on file comparison. I maintain the online documentation for several applications. The documentation is effectively a Web site, a folder full of interlinked HTML and CSS files. I send this off to the application developers, and they make changes and send it back to me. What changes did they make? To find out, I point BBEdit at my version of the folder and at the version of the folder that the developers just sent back to me, and use the Find Differences command. BBEdit tells me whether one folder has files that the other lacks, and also tells me which files are in both but differ; in the latter case, the interface becomes the "compare text files" interface and I can easily see exactly what was changed.
  8. Check HTML validity. I maintain several Web sites as well as online documentation that takes the form of a Web site (did I mention this already?). I generate such a Web site, either editing by hand or using some cool Web site generation tool [4], and now I want to make sure the HTML is valid. BBEdit's Markup menu has a Check Document Syntax command that lets me validate a single file, and a Check Folder Syntax command that lets me validate all the files in a site folder.
  9. Wrangle individual characters. From the massive world of entire Web sites, let's jump down to the miniature world of individual characters. BBEdit provides a number of utilities that assist me when things go mysteriously wrong with characters. For example, as a programmer, I copy some sample code from a Web page, paste it into a text file, try to run it, and it fails with a weird error message. The code looks right, but something seems to be wrong with the text. BBEdit helps me find out what's up. For example, its Hex Dump command lets me examine the file not as text but as numeric codes; sometimes this reveals that the file contains "null" characters, zero bytes that are completely invisible and undetectable in a text editor, but which wreck the code's ability to execute, or shows that it has the wrong kind of end-of-line characters. Or, BBEdit's Show Invisibles command can reveal the presence of incorrect whitespace characters, such as a non-breaking space (Option-Space). Or, I can select an individual character and use BBEdit's ASCII Table palette window to ask, "Just what character is this?" Also helpful when reformatting text copied from some other source is BBEdit's Convert to ASCII command.
  10. Rewrap lines. Finally, from the sublime to the mundane. Line wrapping: how boring is that? But it comes up a lot. Email often has hard-wrapped lines, so if you want to paste an email message into a word processing context, you need to turn those into true paragraphs. Just the other way round, sometimes I want to paste email-style "quoted text" into a text field in my browser (when posting to an online forum, for example), so I need to take continuous text, break it up into shorter lines, and put a greater-than sign in front of each line. BBEdit has simple commands that make all of those things a snap.

There are undoubtedly other ways to do any or all of these things; all I'm reporting here is that I've noticed myself reaching for BBEdit to do them, even though, as I say, BBEdit isn't my choice for editing text. At $125, BBEdit is pricey for just these tasks, and I'm not recommending a purchase for these reasons alone. But if you do have it, some of these uses might not have occurred to you.

Finally, note that BBEdit's freeware little brother, TextWrangler [5], gives you almost all the same abilities. It can't do #6 (it has no version control interface), but you can use its text file comparison interface as an SVN external "diff" helper. It also can't do #8 (it has no Markup menu), but there are other perfectly acceptable validators (such as Robert Crews's freeware Validator [6]).

[1]: http://www.barebones.com/products/bbedit/
[2]: http://www.macosxhints.com/article.php?story=20080601072810282
[3]: http://www.nolobe.com/interarchy/
[4]: http://www.apeth.com/RubyFrontierDocs/
[5]: http://www.barebones.com/products/textwrangler/
[6]: http://homepage.mac.com/rcrews/software/validator/