Our monthly Troubleshooting Tools column, penned by MacFixIt Contributing Editor Dan Frakes, covers products that can help you maintain and fix your Mac.
If you're the type of Mac user who's hip to the latest software, you've surely heard of Bare Bones' TextWrangler. If not, the short description is that TextWrangler is one of the more powerful text editors on any platform, surpassed in some users' minds only by its big sibling, BBEdit, which has more tools for application development and coding and for working with HTML. But unlike BBEdit, which retails for $199, TextWrangler is free.
You may be thinking, "But this is supposed to be a column about troubleshooting tools. Why are you talking about a text editor?" Why, indeed. The fact is that a good text editor comes in handy when troubleshooting by allowing you to view the contents of text files and, when necessary, to edit them. (If you're a longtime reader of MacFixIt, you've surely seen the phrase, "One solution is to edit the file...in a text editor" many times.) So every troubleshooter needs a good text editor, and TextWrangler is my favorite for this purpose.
This begs another question: With all the good text editors out there -- and one, TextEdit, included with Mac OS X -- what makes TextWrangler worth the download? Three features set it apart from most other text editors.
Opening hidden files One of the challenges of troubleshooting Mac OS X is that many of the configuration files used by the operating system are located in hidden directories. If you suspect (based on your own knowledge of the OS or as a result of reading a site such as MacFixIt) that a setting in one of these files might be causing a problem, and you want to access that file, you first have to be able to locate it. (For example, a previous MacFixIt article explained how to disable Spotlight by editing the hostconfig file, located in
Savvy OS X users know that you can locate such files by choosing "Go to Folder" from the Finder's Go menu and then typing the path to the folder containing the file in question; when you click the Go button, the Finder will open that folder. For example, to open the file cupsd.conf, which contains many of the settings for CUPS, Mac OS X's printing system, you would type
/etc/cups and then click Go. But what if you don't know the exact path to the file? You could use a utility such as InVisibiles to make all invisible files visible, but TextWrangler is much easier (especially if you're planning on editing the file anyway) and much less messy.
To browse hidden folders and files from within TextWrangler, choose New -> Disk Browser from the File menu (or press Command Option N). You'll see a new window that shows the contents of your home directory, including folders and all "readable" files (those TextWrangler knows it can open). You can then browse folders and files just as you can in the Finder. To see all files, even those TextWrangler isn't sure it can open -- which is likely what you want to do -- choose All Files from the Show pop-up menu. To instead view the root level of your hard drive -- which includes OS X's hidden Unix folders -- choose your hard drive from the Directory pop-up menu.
As you select folders in the Disk Browser, the bottom of the Browser displays the contents of each folder; if you select a text file, the browser displays a preview of the contents of the file. Double-click any file, or select it and click the Open button, to open it in TextWrangler. (If you know exactly where the file resides, TextWrangler provides a feature similar to the Finder's "Go to Folder" command: Just click the pop-up menu that looks like a folder icon and choose Other; type the path to the file to open it.)
You also have one other option for opening hidden files in TextWrangler: to display them directly in the standard Open dialog. To do this, instead of choosing Open from the File menu, choose Open Hidden; in the resulting dialog, choose All Files from the Enable pop-up menu. Just as with the Disk Browser, the Open dialog lets you navigate to any file in any directory for which you have at least Read privileges (which includes most system-level directories). Select a file and click the Open button to open it in TextWrangler.
Editing system-level files Another troubleshooting challenge posed by Mac OS X is that many of the System-level files you might need to work with to fix a problem are owned by the system or root user. You can usually view the contents of these files from within your own user account, but you won't be able to edit them without authorization.
One way around this limitation is to launch your favorite text editor as root (as explained previously), but TextWrangler makes the process even easier. When you open such a file in TextWrangler and then try to make any change, a dialog appears telling you that the file is owned by the root user and asking if you want to unlock it. If you click Yes, TextWrangler will allow you to work with the file. When you're ready to save the changes you've made to the file, TextWrangler will ask you for your admin-level username and password; providing them saves the changes you've made. (This procedure is effectively the same as editing the file as root.)
You obviously shouldn't edit a system-level file in this manner unless you know what you're doing -- and even then you should make sure to back up the original, unmodified file first -- but in a situation where you need to do so, TextWrangler is generally the easiest way. (And unlike launching a text editor as root, TextWrangler will prompt you, before allowing you to make changes, for each additional system-level file, so you don't have to worry about changing something unintentionally.)
(One caveat: When working with settings files in Mac OS X, make sure you set TextWrangler to save text documents with Unix line breaks; this setting is located in the Text Files: Saving screen of TextWrangler's Preferences dialog.)
Accessing TextWrangler from Terminal One other feature of TextWrangler that makes it useful for troubleshooting -- at least for those users who enjoy using Mac OS X's command-line environment -- is TextWrangler's command-line tools. When you first launch TextWrangler, you're asked if you want to install these tools. If you agree (and provide an admin password to authorize the installation), two new command-line applications will be available:
twdiff. (If you previously declined the offer, you can install these tools via the Tools screen of TextWrangler's Preferences dialog.) Although
twdiff isn't that useful for troubleshooting, the
edit command lets you use TextWrangler to edit files via Terminal instead of a command-line text-editing program such as
For example, if I'm viewing my home directory in Terminal, and I see an invisible file called .bash_history -- which is invisible in the Finder -- I can open it in TextWrangler by typing
edit .bash_history. Any changes I make, and then save, in TextWrangler will be saved to the hidden file.
I can also use the
edit tool to create a new invisible file. For example, if I'm using the
tcsh shell and I want to create a tcsh configuration file called .tcshrc in my home directory, I can do so by typing
edit ~/.tcshrc; the new file will be created and opened in TextWrangler, where I can edit it.
This command-line functionality isn't for everyone, but for those who are frequent Terminal/shell users, it's a very cool tool. And if you ever come across a troubleshooting procedure that calls for you to use
vi to edit a file, using TextWrangler is much, much easier.
These three features make TextWrangler a must-have tool in my troubleshooting toolbox (and I haven't even touched the myriad general text-editing features it has). Granted, if you're an administrator who needs to access files located in directories for which you don't even have Read privileges -- for example, the home directories of other users -- TextWrangler can't help you unless you launch it as root (for example, using Pseudo, as explained in a previous column). But for most troubleshooting and administrative tasks, TextWrangler has all the text-editing features and power you'll need.
Contributing Editor Dan Frakes is a former MacFixIt Editor, and is currently a Senior Editor at Macworld and the Reviews Editor for Playlist. To provide feedback on this column, or to suggest utilities for future columns, drop Dan an email at his @MacFixIt.com address: dfrakes.Resources