Text Filters

Text filters operate on the selected text of the frontmost document (or on the whole document if there is no selection).

The selection will be replaced with the filtered text (or the whole document if there is no selection).

A text filter may be a Unix script, AppleScript file, BBEdit Text Factory, or Automator workflow.

Text filters live in the “Text Filters” support folder. To get there quickly, choose “Text Filters” from the “Folders” menu on the BBEdit application menu, which will open a Finder window on the correct location.

To use a Text Filter, select Menu_Bar > Text > Apply Text Filter > your_filter_name

To easily edit a text filter hold down the Option-key when selecting one from the “Apply Text Filter” menu.

Holding down the Shift key when selecting a text filter will reveal it in the Finder.

Notes:

The selected text (or front document contents, if there is no selection) is supplied as standard input (STDIN) to Unix scripts and executables, as a reference to a `RunFromBBEdit` entry point in AppleScripts, as text input to Automator workflows, and as a source to text factories.

Examples of Unix scripts:

Transform tab-delimited text into columns:

#!/usr/bin/env bash
column -t -s '	';

Change “http” to “https” in URLs:

#!/usr/bin/env bash
sed -E 's!http://!https://!';

Find Every Email Address – Sort – Remove Duplicates:

#! /usr/bin/env perl -0777 -nsw
my @array = m!\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b!ig;
my %hash = map { $_ => 1 } @array;
my @unique = sort(keys %hash);
$, = "\n";
print @unique;

A python script for ROT-13:

#!/usr/bin/env python

import fileinput
import string

unshifted = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
shifted =   'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM'
rot13_table = string.maketrans(unshifted, shifted)

for my_line in fileinput.input():
    print string.translate(my_line, rot13_table),

User created Text Filters