Документация
HTML CSS PHP PERL другое

Section C.5.  TextWrangler

 
Previous
Table of Contents
Next

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 TextSection C.5.  TextWranglerShow 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 FileSection C.5.  TextWranglerSave 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 FileSection C.5.  TextWrangler"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 WindowsSection C.5.  TextWranglerPalettesSection C.5.  TextWranglerUnix 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

    Previous
    Table of Contents
    Next
    © 2000- NIV