Espresso

Indentation and Whitespace

Indenting

To indent or outdent lines, select them and choose Text ⟩ Shift Right (command ]) or Text ⟩ Shift Left (command [). You do not need to select whole lines: any line that is partly selected is shifted, and with nothing selected, the line the cursor is on.

With text selected, tab and shift tab do the same.

With nothing selected, tab inserts a tab, or the spaces that stand for one. At the start of a line, it takes the cursor straight to where the line belongs under the lines around it.

New lines

Pressing enter starts a new line with the indentation it should have: the same as the line before, or a step further in after an opening brace or tag. Between a pair that has just been opened, such as { and }, it opens the pair out, with the cursor on an indented line between them.

Three commands in Text ⟩ Text start a line in other ways:

So if you have <div>|</div> (the pipe is the cursor) and press control enter you get:

<div>
    |
</div>

Brackets and quotes

When you type an opening bracket or quote, Espresso types the closing one for you, and when you then type the closing one yourself, it steps over the one that is there. Deleting an opening bracket that has nothing in it yet deletes its partner too. Select some text and type a bracket or quote to wrap the selection in the pair.

Which characters pair up depends on the language. In HTML text, for instance, an apostrophe is left alone, while inside a tag quotes come in pairs.

Re-indenting

Espresso can lay code out again from its structure:

When you open a document that has been minified, a bar at the top offers to re-indent it so that it is easier to read and edit.

Tabs or spaces

Espresso decides how a document is indented from, in order:

  1. An .editorconfig file, if one applies to the document
  2. The document itself. If its lines are already indented in one clear way, Espresso carries on in that way. You can turn this off with Use a file's own indentation when it is clear in the Text Editing preferences.
  3. What you have chosen for the document's language
  4. The Text Editing preferences

To see or change the indentation of the document in front, use the View ⟩ Indentation menu. Choose Tabs or Spaces, and a width of 2, 3, 4 or 8. For tabs, the width is how wide a tab is shown.

Choose View ⟩ Indentation ⟩ Use for This Language to have every document of this language start out with these choices. Choose it again to take that back.

Changing these does not change the text that is already in the document. To convert a document's existing indentation, use Text ⟩ Convert / Strip ⟩ Spaces To Tabs… or Tabs To Spaces….

Line endings

Espresso keeps the line endings a file already has. The View ⟩ Line Endings menu shows which they are: Unix (LF), Mac Classic (CR) or Windows (CRLF). Choose another to convert every line ending in the document.

New documents get the line endings chosen in the Text Editing preferences.

.editorconfig

If your project has an .editorconfig file, Espresso follows it, ahead of its own preferences. These properties are understood:

Tidying when you save

Two options under When Saving in the Text Editing preferences tidy a document each time it is saved:

Both are off to begin with, and an .editorconfig file that says otherwise for a file wins.