Espresso

General Actions

Espresso's general actions are useful in a wide variety of languages. They are at the top of the Text menu and in its Convert / Strip and Text submenus. See also the actions for working with lines and for selecting text.

Duplicating, shifting and commenting

Text ⟩ Duplicate (command D) and Duplicate Line (shift command D)

Duplicate writes the selected text again after itself. Duplicate Line writes the line the cursor is on, or every line of the selection, again beneath.

Text ⟩ Shift Left (command [) and Shift Right (command ])

Move the selected lines, or the line the cursor is on, a step of indentation out or in.

Text ⟩ Un/Comment (command /)

Un/Comment's behavior depends on whether you have a selection or not:

If there is already a comment, the action will uncomment your text instead of commenting it out. Un/Comment also has a button in the toolbar.

Text ⟩ Re-Indent Selection, Re-Indent All, Re-Indent with Spacing… and Delete and Re-Indent (command delete)

These lay your code out again from its structure. See Re-indenting.

Convert / Strip

Text ⟩ Convert / Strip ⟩ Spaces To Tabs… and Tabs To Spaces…

These two actions will convert between spaces and tabs within leading whitespace. If you select one or more lines, only those lines will be converted; otherwise the whole document will be converted. When you run the action, Espresso will ask you how many spaces should represent one tab.

Text ⟩ Convert / Strip ⟩ Straighten Quotes, Curl Quotes and Curl Quotes As HTML Entities

Straighten Quotes turns typographer's quotes (“ ” ‘ ’) into the plain ones that code needs, which is useful for text that has come from a word processor. Curl Quotes does the opposite for prose, and Curl Quotes As HTML Entities writes the curled quotes as entities such as “.

Text ⟩ Convert / Strip ⟩ Uppercase, Lowercase and Title Case

Change the case of the selected text, or with nothing selected, of the word the cursor is in.

Text ⟩ Convert / Strip ⟩ Trim Lines

If you have a selection, Trim Lines will strip the whitespace from the ends of each line in the selection. Otherwise, it will trim all lines in the document. Indentation is left as it is.

To have this done every time you save, see Tidying when you save.

Text ⟩ Convert / Strip ⟩ Zap Gremlins…

Particularly if you are copying and pasting text from other programs, you can sometimes end up with invisible characters in your document that are rendered in HTML as gobbledegook. Zap Gremlins allows you to easily strip these characters. When you start Zap Gremlins, it will look for invisible characters and unusual spaces in your selection or document and let you know how many of each there are. You can then choose to remove the invisible characters, and to remove the non-standard spaces or replace them with a normal space or with  .

Text

Text ⟩ Text ⟩ Move Line Up (control command up)

Choose this menu item or hit control command up to swap the line your cursor is in with the line above it (if you have multiple lines selected, all selected lines will be moved).

Text ⟩ Text ⟩ Move Line Down (control command down)

This action is identical to Move Line Up except that, shockingly, it switches the current line or selected lines with the line below.

Text ⟩ Text ⟩ New Line Below (command enter) and New Line Above (shift command enter)

Start a new line under or above the current one, wherever in the line your cursor is, without breaking the line. This is particularly useful when using CodeSense in CSS, for instance.

Text ⟩ Text ⟩ Indent New Line (control enter)

Indent New Line creates a new line and increases the indentation level by one. Additionally, if there is text after the cursor on the current line, it will be moved down to its own line beneath the new line. So if you have this (pipe represents the cursor):

<div>|</div>

And hit control enter you will end up with this:

<div>
    |
</div>

This is a very handy shortcut to memorize, as it can make writing well-indented code much simpler.

Text ⟩ Text ⟩ Insert Linebreak(s) (control shift enter)

Insert Linebreak(s) will insert different things depending on the context:

If you have multiple selections, the text will be inserted at the end of every selection.

Text ⟩ Text ⟩ Insert Tab In Tab Stop (option tab)

When working with snippets you may find yourself needing to enter a literal tab character while in a tab stop (normally, if you hit tab in a tab stop it will move you to the next tab stop). To do so, hit option tab instead.

Text ⟩ Text ⟩ Wrap With… (command ')

Wrap With… allows you to wrap selected text with arbitrary characters. To use it, select something and hit command ', then enter the character you wish to wrap around the text; a sample shows what you will get. Wrap With will automatically balance characters (like brackets, quotation marks, and more) with the appropriate opposite character. So if you select the text some text, hit command ', and enter a [ character, you will get:

[some text]

If you enter more than one character, they will be properly nested. In the example above, if you typed [!## you would end up with:

[!##some text##!]

You can also enter non-symbol characters if for some reason you need to wrap text with other letters.