Using Atom packages

Package Power

Article from Issue 182/2016
Author(s):

The Atom text editor's default functionality can be extended using packages. We look at packages that coders and writers alike may find rather useful.

Atom is a powerful and flexible text editor as it is, but thanks to its extensible architecture, you can teach it some useful tricks by installing additional packages. The official package repository [1] contains hundreds of modules. Some of them add very specific features, whereas others bring improvements that enhance the overall user experience and make coding and writing in Atom more efficient. Need packages like these? Then read on.

There's a Package for That

Sometimes a seemingly minor improvement can have a significant effect. The Seti Icons package [2] is a case in point. Once installed, this package replaces the default Atom icon set. At first sight, the change is purely cosmetic: The icon set uses a different color palette. This is an improvement in itself, but look closer, and you'll notice that this icon set does a much better job of differentiating files by their type (Figure 1). Although the default Atom icon set has one icon for all text file types, the Seti Icons package has dedicated icons for each file type. In practice, this means that you can immediately identify HTML, Markdown, and text files by their icons. This may not sound like much, but if you try the Seti Icons package, you might find it difficult to go back to the default icon set.

Figure 1: The Seti Icons package offers a better alternative to the default icon set.

The Drag-and-Drop Text package [3] solves another small but important problem for users who prefer to use the mouse when working with text. By default, Atom doesn't support moving text selections with the mouse; however, the Drag-and-Drop Text package fixes this deficiency. Although it supports several actions, their behavior is slightly different from what you might expect. To drag and copy a text fragment, you make a selection, press and hold the left mouse button on the selected text, wait until you see a red border around the selection, drag the mouse to the desired location in the text, and release the button. To move a text fragment, you make a selection and hold the left mouse button on it until the selection disappears, drag the mouse to another location in the text, and release the button. If you release the left button before you move the mouse to the desired location, the described steps perform copy-and-paste and cut-and-paste actions.

Atom supports a vast number of keyboard shortcuts (or keybindings), so you can perform practically any action without lifting your hands from the keyboard. The tricky part is to remember all the shortcuts, or at least the most useful ones. Keybinding Cheatsheet package [4] to the rescue. Once installed, it lists all actions and their keybindings in a separate sidebar (Figure 2). To toggle the Keybindings sidebar, use the Ctrl+Alt+/ shortcut or run Keybinding Cheatsheet: Toggle in the Command Palette.

Figure 2: The Keybinding Cheatsheet package lists all of Atom's keybindings.

Versioning is an essential feature for many coders and writing professionals. If you happen to use Git as your preferred version control system, then the Git History package [5] is right up your alley. For a less technical solution, the Local History package [6] is the way to go. As the name suggests, this package keeps a history of all edits for each file, and you can easily view previous versions of the file as well as compare different versions using a so-called diff tool (by default, the package uses the Meld tool available in the software repositories of many Linux distributions). Local History stores file versions in the ~/.atom/local-history directory, which makes it easy to create backups and extract the version you need manually.

Speaking of history, the Clipboard History package [7] can improve the default clipboard functionality by storing a list of all selections made during an editing session. The package requires no configuration (although it has a couple of settings you can tweak) and is dead easy to use: Press the Ctrl+Shift+V keyboard shortcut and select the desired selection item from the drop-down list.

It's common programming practice to use the CHANGED, TODO, and FIXME labels in comments to flag the parts of the code that have been modified, require additional work, and need fixing. However, nothing stops you from using this technique in regular text to mark paragraphs and text segments that require attention. Although you can use Atom's search functionality to find these labels in the text, The TODO Show package [8] provides a more elegant and efficient way of dealing with them.

This package uses a dedicated sidebar to list all marked fragments neatly grouped by the label. The package can find labels in the opened files as well as in all files in the current project. To toggle the sidebar, use the Shift+Alt+T keyboard shortcut or run the appropriate Todo Show command from the Command Palette.

The package uses regular expressions to find the default labels, but you can define custom regular expressions for other labels by modifying the basic rule that looks like this:

'/\\b@?TODO:?\\d*($|\\s.*$)/g'

Adding the COMMENT label, for example, is a matter of replacing the TODO part of the rule as follows:

'/\\b@?COMMENT:?\\d*($|\\s.*$)/g'

To add this rule to TODO Show, switch to the Settings | Packages section, press the Settings button next to the TODO Show item, and enter the rule into the Find These Regexes field (Figure 3).

Figure 3: TODO Show can locate specific labels in files and projects.

GitHub Gist is a handy service for sharing code snippets and text fragments (gists in GitHub terminology), and the Gist It package [9] allows you to publish files and text selections directly from within Atom. By default, all gists are published anonymously, but you can change that by generating a GitHub token. To do this, point your browser to github.com/settings/tokens/new and generate a new token with the gist scope; then, paste the token into the OAuth Token field in the package's settings. To post the current file or text selection to Gist, use the Ctrl+Alt+G and Shift+Ctrl+Alt+G keyboard shortcuts, respectively.

No matter how proficient you are at writing, the Linter Write Good package [10] can prove to be a useful addition to your toolbox. Although Linter Write Good won't magically transform your writing into a literary masterpiece, it can help you to identify and avoid common grammar and style issues (Figure 4). Among other things, the package can check for weasel words (e.g., somewhat, probably, some, most, etc.), use of passive voice, cliches, wordy phrases and unnecessary words, and adverbs that can weaken the meaning (really, very, extremely, etc.). To make Linter Write Good work, you also need to install the Linter package. Once enabled, Linter Write Good automatically parses the text, flags detected issues, and lists them in the bottom pane. You can then work through the list to fix the detected issues.

Figure 4: Lint Write Good helps to improve writing by identifying common grammar and style issues.

Markdown Creature Comforts

Markdown is a popular lightweight text formatting markup for authoring anything from README files and documentation to articles and ebooks. If it happens to be your preferred formatting option, you might find several handy Atom packages useful. Atom supports Markdown out of the box, and the editor allows you to display Markdown-formatted text and its preview side by side using the Packages | Markdown Preview | Toggle Preview command (or the Shift+Ctrl+M shortcut).

There is a tiny bump in the road, though: The editor doesn't keep the text and preview panes in sync, which can quickly become an annoyance when working with a long text requiring a lot of scrolling. The Markdown Scroll Sync package [11] fixes this issue (Figure 5). The Markdown Format [12] and Tidy Markdown [13] packages can help you to keep your Markdown-formatted text neat and clean by fixing common problems like double spaces, bad indentation, incorrect list numberings, and so on.

Figure 5: Markdown Scroll Sync keeps the original Markdown-formatted file and its preview in sync when scrolling.

Do you need to generate a table of contents (TOC) for a long Markdown-formatted document? Markdown TOC [14] does the trick. This package supports several useful options, including TOC depth and automatic linking of TOC entries using anchor tags. Markdown TOC can also refresh the table of contents automatically every time you save the file.

Transform Atom into an Outliner

Designed to organize and manage text as a hierarchical tree, an outliner makes a perfect companion to a text editor. Instead of using a dedicated outliner, you can add outlining capabilities to Atom, courtesy of FoldingText [15]. Install the package, and you can create a new outline using the File | New Outline command (Figure 6). Mastering FoldingText's basics doesn't require a lot of effort. Press Enter to create a new entry in the current outline, hit Tab to indent the entry (i.e., move one level down), and use the Shift+Tab shortcut to un-indent the entry (i.e., move one level up). You can rearrange the entries in the outline by dragging them with the mouse, as well as collapse and expand the entries.

Figure 6: FoldingText transforms Atom into a capable outliner.

In addition to this basic functionality, FoldingText has a few clever tricks up its sleeve. The Ctrl+Space shortcut, for example, can be used to mark the current entry as completed, which means that you can use the outline as a simple way to manage tasks. FoldingText also makes it possible to assign tags, status labels, and priorities, and the package features the dedicated outline mode for speedy and efficient tagging and prioritizing.

To enter the outline mode, press the Esc key. You can then quickly assign tags to the currently selected entry by typing t. Each status in FoldingText has its own shortcut, too: Type s t for todo, s w for waiting, s a for active, and s c for complete. Assigning priorities in the outline mode is even easier: use number keys from 1 to 7 to add appropriate priority labels. FoldingText also features filtering functionality. Using it, you can limit the outline to a subset of entries matching a specific tag, status, or priority. To apply a filter, click on the desired tag, status, or priority label.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News