Text Editor Actions for Espresso

Text Editor Actions for Espresso (TEA for short) includes several useful actions for editing HTML and other text, as well as providing an easier way to create custom Espresso actions than coding a full-blown Sugar in Objective-C. You will find:

  • some awesome Textmate-inspired commands like Wrap Selection In Tag, Spaces to Tags, Trim, and many more
  • zen coding support
  • custom actions defined in XML and coded using the language of your choice
  • full access to the Espresso APIand Cocoa using Python or Javascript (Javascript requires Spice)

The bundled commands

TEA currently includes:

  • Spaces To Tabs… and Tabs To Spaces…
  • Trim Line(s)
  • Select Word, Line, or Line Contents
  • Select Balanced Tag, Select Balanced Tag Inwards
  • Sort Lines: ascending, descending, and randomly
  • Remove Duplicate Lines
  • Indent New Line (to emulate Textmate’s intelligent creation of indented blocks)

HTML

  • Insert Linebreak(s) with support for <br /> in HTML and \n in other languages
  • Strong and Emphasize
  • Convert to Named or Numeric Entities
  • Insert Non-Breaking Space, and other common entities
  • Expand Abbreviation (zen coding)
  • Wrap With Abbreviation (zen coding)
  • Wrap Selection In Tag
  • Wrap Selected Lines In Tag
  • Wrap Selection In Link (support for HTML, Markdown, and Textile)
  • Documentation For Tag

Learn more about TEA’s bundled actions in the documentation.

Zen coding

If you have not encountered it yet, the zen coding project is about to change the way you write HTML. Zen coding offers a simple syntax based on CSS selectors that allows you to quickly create complex markup. Running this through TEA’s Expand Abbreviation action:

div#stuff.things.booyah

Results in this (pipe represents cursor):

<div id="stuff" class="things booyah">|</div>

You can additionally create nested or sibling elements, along with numerous other features, like automatic incrementing classes and more.

div#nav+div#content>p.item$*2

Leads to:

<div id="nav">|</div>
<div id="content">
    <p class="item1"></p>
    <p class="item2"></p>
</div>

Better yet, all your zen coding expansions come complete with tab stops to make filling them out with content even quicker. Zen coding also provides a comprehensive list of abbreviations for expanding commonly-used HTML, CSS, and XML snippets.

Learn more about zen coding in the zen coding wiki.

Custom actions

Defining a custom action is as easy as creating an Espresso TextAction definition and placing the XML file containing it in ~/Library/Application Support/Espresso/Support/TextActions/.

TEA includes a rich library of generic actions that are the basis of the bundled commands and which can be modified through XML alone. If you wish to define a new action, however, you can use the shell-friendly language of your choice (PHP, Ruby, Perl, etc.) just like for Textmate bundle commands. Or, if you need access to the full Espresso API, simply use Python and speed up development with TEA’s utility functions (and Spice offers an even easier full-API approach using Javascript).

Learn more about custom actions in the TEA documentation.

Sweeten your TEA

Although TEA includes the bulk of my favorite Textmate actions, you may also be interested in the HTMLBundle.sugar, which adds most of the other Textmate HTML bundle actions that for one reason or another I didn’t think deserved inclusion with TEA.

Clicky Web Analytics