Change color of BBEdit and TextWrangler 'invisibles' characters
Bare Bones Software's two text editing applications, BBEdit and TextWrangler, have the ability to show invisible characters in your documents—spaces, tabs, line breaks, page breaks, and control characters. Using the View -> Text Display menu, you can choose to see either just the invisible characters, or the invisible characters and spaces—when active, these invisible characters are replaced by visible entities.
The visible characters are split into two groups for color purposes. Control characters, and other oddities that normally appear in red are in one group, and spaces, tabs, carriage returns, non-breaking spaces, and page breaks are in the other group, which are gray by default. If you prefer to use a light gray (or perhaps red?) background, this can be a problem. Thanks to Mac OS X Hints readers CkB_Cowboy and Mark Johnson, however, you can actually customize the colors of these characters, with a little help from Terminal.
To set the color for these two groups, you first need to decide which color you’d like to use. If you’ve got an image editor that can display colors with their 16-bit RGB values, you can use that to find a color you like.
If you don’t own such a program, you can use Digital Color Meter (in Applications -> Utilities) instead. Launch it, set the pop-up menu to “RGB as Actual Value, 16-bit,” then move the mouse around the screen until it’s over the color you’d like to use. Press Command-L to lock that screen area, then note the values next to the R, G, and B labels in the program’s window, as seen in the image at left.
Launch Terminal, and position the Digital Color Meter window such that you can see it as well as the Terminal window. Quit BBEdit/TextWrangler if they’re running, then switch to Terminal. You’ll need two commands to set the color for both sets of characters (so you can set them to different colors, if you wish). The commands also differ slightly for TextWrangler and BBEdit, as the apps use different preferences files.
Before modifying files, make sure you’ve got backups of the files you’ll be modifying, either on Time Machine, or just make a quick copy yourself. The affected files are in your user’s Library -> Preferences folder. If you use BBEdit, back up com.barebones.bbedit.plst; if you’re a TextWrangler user, back up com.barebones.textwrangler.plist.
To set the color of spaces, tabs, and the other “normal” invisible characters, use one of these two commands, depending on which app you’re using:
defaults write com.barebones.bbedit Color:Invisibles:Spaces -string "rgb(x,y,z)" defaults write com.barebones.textwrangler Color:Invisibles:Spaces -string "rgb(x,y,z)"
The color of the control characters is set with one of these two commands:
defaults write com.barebones.bbedit Color:Invisibles:Other -string "rgb(x,y,z)" defaults write com.barebones.textwrangler Color:Invisibles:Other -string "rgb(x,y,z)"
Don’t paste those exactly as they are—first replace
z with the 16-bit RGB values you got from your graphics program or Digital Color Meter. To use the color specified in the above screenshot, for example, I’d use
After you’re done, launch BBEdit/TextWrangler, and open a new document. Select View -> Text Display -> Show Invisibles, and then select Show Spaces from the same sub-menu. If it looks like your command didn’t work, don’t fear—it seems there’s a glitch that sometimes affects the first document opened after launch. Just open a new window, or open another document, and things should work as described.
If you decide you want the default colors back, quit BBEdit/TextWrangler, then run these commands in Terminal. For BBEdit:
defaults delete com.barebones.bbedit Color:Invisibles:Spaces
defaults delete com.barebones.bbedit Color:Invisibles:Other
For TextWrangler, the commands are:
defaults delete com.barebones.textwrangler Color:Invisibles:Spaces
defaults delete com.barebones.textwrangler Color:Invisibles:Other
The next time you launch either editor, the colors for invisible characters will be back to normal.