Espresso's general actions are useful in a wide variety of languages, and are broken down into three main groups: actions that convert or strip whitespace, actions for working with multiple lines, and actions for selecting text.
Actions ⟩ Un/Comment (command /)
Un/Comment's behavior depends on whether you have a selection or not:
- if there is a selection, Un/Comment will wrap the selected text in a comment
- if there is no selection, Un/Comment will comment out the current line
If there is already a comment, the action will uncomment your text instead of commenting it out.
Actions ⟩ 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, the program will ask you how many spaces should represent one tab (defaults to whatever you have set in the Espresso preferences).
If you have a selection, Trim Lines will strip all non-indent whitespace from the beginning and end of each line in the selection. Otherwise, it will trim all lines in the document.
Because it attempts to preserve indentation whitespace, Trim Lines can be useful to remove extra spaces in a line that is indented with tabs.
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 in your document and let you know how many there are. You can then choose to do nothing or remove invisible control characters, and optionally transform non-breaking spaces into normal spaces.
Actions ⟩ 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).
Actions ⟩ 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.
Actions ⟩ 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):
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.
Actions ⟩ Text ⟩ Insert Linebreak(s) (control shift enter)
Insert Linebreak(s) will insert different things depending on the context:
- Default (HTML):
- Markdown: two spaces and a linebreak
If you have multiple selections, the text will be inserted at the end of every selection.
Actions ⟩ 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.
Actions ⟩ 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. 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:
If you enter more than one character, they will be properly nested. In the example above, if you typed
[!## you would end up with:
You can also enter non-symbol characters if for some reason you need to wrap text with other letters.