资源说明:A handy collection of actions for keeping your fingers on your keyboard in the Espresso text editor for Mac
` in an HTML document, you will end up with `# Handy.sugar A collection of text actions for [Espresso](http://macrabbit.com/espresso/) that keep your hands on the keyboard, written in Javascript. ## Breaking changes in Handy 2.0 * **Requires Espresso 3.0** * **Selection editing actions are gone.** Espresso 3 has native support for editing multiple cursors or selections, making these actions redundant. * **"Edit selected lines" actions now use the old "edit selection" shortcuts**; they also utilize multiple cursors instead of snippets. * **Select All Copies shortcut now moves upward through the Item hierarchy with each successive use**; a new shortcut is available for selecting all copies of a word in the document. ## Installation **Requires Espresso 3.0**; use [Handy v1.8.0](https://github.com/onecrayon/Handy.sugar/releases/tag/v1.8.0) for Espresso 2. 1. [Download Handy.sugar](http://onecrayon.com/downloads/Handy.sugar.zip) 2. Decompress the zip file (your browser might do this for you) 3. Double click the Sugar to install it Optionally, you can clone it from GitHub for easier updating: cd ~/Library/Application\ Support/Espresso/Sugars git clone git://github.com/onecrayon/Handy.sugar.git Relaunch Espresso, and a new Handy submenu will be available in your Actions menu. You can then update the Sugar when necessary by running the following command: cd ~/Library/Application\ Support/Espresso/Sugars/Handy.sugar git pull ## Available actions Handy.sugar currently includes the following actions: * **Align Assignments**: vertically aligns all assignment operators in the selected lines // So this: foo = 'bar'; blag = 'blarg'; fibbles = 'McGee'; // Gets transformed into this: foo = 'bar'; blag = 'blarg'; fibbles = 'McGee'; * **Increment/Decrement** by 1 or 10: increase or decrease the numeric value under the cursor, in the current selection, or across multiple selections * **Quick Switch Tag**: quickly rename the nearest wrapping HTML or XML tag, and then hit tab to jump straight back to what you were editing ### Selection and cursor actions * **Select Nearby Copies of Word/Text** and **Select All Copies of Word/Text**: selects all instances of the word under the cursor. If you have a selection, all instances of the selected text will be selected instead. When selecting "nearby", selections will be constrained to the nearest parent Item block (this is what is shown in the Navigator). Invoking the "nearby" action multiple times will expand the context upward through the hierarchy; for instance, this allows you to easily select all instances of a variable within a particular function or class. * **Select Column Up/Down**: when you have a selection that is contained within a single line, these two actions allow you to select text in a column vertically across nearby lines. The selection skips empty lines, lines that have nothing but whitespace (unless your selection is nothing but whitespace), and lines that do not extend far enough to contain the whole selection. _Please note_: a soft-wrapped line is still counted as a single line. * **Cursor To Line Start/End** and **Bookend Line With Cursors**: modify the cursors for all selected lines (this includes lines with a cursor/selection inside them as well as multiple lines within a larger selection, but excludes lines composed of nothing but whitespace). Cursors will hug line contents (so Cursor To Line Start will place the cursor after the leading whitespace but before the actual content of the line). * **Combine Selected Ranges**: inclusively select everything from the first selection to the last selection in the document * **Select Text Between Selected Ranges**: select everything between the first and last selection in the document (excludes the selections themselves) ### Hidden actions * _Prevent duplicate semicolons_: typing a semicolon at the end of a CSS property will not result in duplicate semicolons anymore if there is already one there (will instead move your cursor outside the property) * _Documentation comments_: creating a linebreak inside of a documentation comment in PHP or JavaScript will automatically add a leading asterisk to the next line. Documentation comments are formatted like so: /** * My documentation comment */ Additionally, typing `/**` will automatically insert a documentation comment snippet. * _Auto-indent within braces_: hitting enter next to an opening brace character (`(`, `[`, or `{`), will increase the level of indentation on the next line. For balanced braces, it will also move the closing brace to its own line. * _Auto-indent closing braces_: typing a closing brace alone on a line will automatically adjust its indentation level to the same as its matching opening brace; this applies to `)`, `]`, and `}` * _Close tag mistakes_: if you accidentally type a full closing tag in HTML or XML, the extra characters will be automatically removed. For instance, if you type `