Section C.5. TextWrangler


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 http://www.barebones.com/products/textwrangler/.

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 application.pl and ~/Library/Application Support/TextWrangler Support/Stationery/perl module.pm.

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 debug.pl, 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 debug.pl, 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/benchmark.pl file might contain:

  #! /usr/bin/perl -- use Perl6::Slurp; my $selection = slurp; print <<"END_REPLACEMENT" use Benchmark qw( cmpthese ); cmpthese -10, {     $selection }; END_REPLACEMENT



Perl Best Practices
Perl Best Practices
ISBN: 0596001738
EAN: 2147483647
Year: 2004
Pages: 350
Authors: Damian Conway

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net