Previous Page
Next Page

C.5. TextWrangler

TextWrangler is a free text editor from the makers of BBEdit. Although it has a comparatively restricted set of features, it is still extremely capable and easy to use. You can download a free copy of it from

First, adjust your preferences settings. In the Editor Defaults screen under Preferences:

  • Turn on Auto-Indent.

  • Turn on Balance While Typing.

  • Turn on Auto-Expand Tabs.

  • Turn on Show Invisibles.

Adjust your tab stops to four spaces using the option under TextShow Fonts.

You can create stationery for any boilerplate file templates you wish to load by using TextWrangler to create a file containing the desired code. When the code template is ready, select FileSave As... and turn on the "Save as Stationery" option. Save the file to the folder ~/Library/Application Support/TextWrangler Support/Stationery/. It will then be available from the Stationery palette, or via the standard menu item File"New with Stationery". For example, you might create the stationery files ~/Library/Application Support/TextWrangler Support/Stationery/perl and ~/Library/Application Support/TextWrangler Support/Stationery/perl

To use abbreviations in TextWrangler, you need to write a small Perl script that will generate the text you want by filtering the current selection. First, create the folder ~/Library/Application Support/TextWrangler Support/Unix Support/Unix Filters/. Then, add a file named, with the following contents:

#! /usr/bin/perl --
print 'use Data::Dumper qw( Dumper );\nwarn Dumper [ ', <>, ' ]';

You can then assign this filter to a particular keystroke using the palette available from the WindowsPalettesUnix Filters menu. Thereafter, typing that keystroke will take the current selection, pass it to the standard input of, and replace the selection with the output of that script.

Create as many text filters as you wish. For example, a ~/Library/Application Support/TextWrangler Support/Unix Support/Unix Filters/ file might contain:

#! /usr/bin/perl --
use Perl6::Slurp;

my $selection = slurp;

use Benchmark qw( cmpthese );
cmpthese -10, {

    Previous Page
    Next Page