Atom editor

Atomic Writing

Article from Issue 171/2015
Author(s):

Although Atom is designed for developers and coders alike, writing professionals can also benefit from this powerful text editor.

Despite a plethora of available writing tools and platforms, a text editor still remains the weapon of choice for many writing professionals. And, although text editors like Gedit, Kate, and nano are perfectly adequate for drafting articles and scribbling notes, a more powerful and extensible application like Atom [1] can prove to be an essential tool for serious writing.

Installing and Configuring Atom

The project's website provides binary packages for several platforms, including a package for 64-bit versions of Ubuntu and Red Hat. No software repositories exist, so you have to download and install all future releases manually. However, if you happen to use Ubuntu, you'll be pleased to learn that the WebUpd8 team maintains a PPA containing Atom for both 32-bit and 64-bit versions of Ubuntu. Installing Atom from this PPA can be done using the following commands:

sudo add-apt-repository ppa:webupd8team/atom
sudo apt-get update && sudo apt-get install atom

The first order of business after you've installed Atom is to configure its basic settings (Figure 1). To do this, press Ctrl+<comma> (or choose Edit | Preferences). This opens the Settings interface in a separate tab. Most options in the Core Settings section are self-explanatory, so you shouldn't have problems configuring them.

Figure 1: Tweaking Atom's basic settings.

Atom's configurability goes well beyond the basic options in the Settings section, though. Practically every aspect of the editor can be customized by specifying options in the dedicated ~/.atom/styles.less stylesheet. To open it for editing, choose Edit | Open Your Stylesheet. Specifying custom options here requires a working knowledge of CSS and LESS [2], but you can learn a lot by studying styles.less files shared by other Atom users on GitHub Gist [3]. To get started, you can change the default line spacing by specifying the following option in the styles.less stylesheet:

.editor { line-height: 1.5 }

Like any other serious text editor, Atom supports snippets, or abbreviations, that automatically expand into predefined text. For example, you can create a snippet that replaces the fig abbreviation with Figure 1. Caption. text. To edit snippets, choose Edit | Open Your Snippets. Snippets in Atom have the following format:

'.text.plain':
    'Figure':
        'prefix': 'fig'
        'body':'Figure 1: Caption.'

The first key defines the scope (i.e., file types where the snippet can be used). In the example above, .text.plain indicates that the snippet can be used in all plain text files. The second key specifies the name of the snippet (in this case, it's Figure). The prefix key defines the abbreviation for the snippet, whereas body contains the text fragment that replaces the abbreviation. The latter key can contain multiline text fragments, but they must be wrapped into double quotes as follows:

'body':"""
    fig1.png
    Figure 1: Caption.
    """

Snippets can contain placeholders, too. For example, instead of the fig1.png Figure **1: Caption. text fragment with the hard-wired figure number, you can use the $1 placeholder: fig$1.png Figure $1: Caption.. This way, when you expand the abbreviation, the placeholders are replaced with multiple cursors, so you can insert the desired number in one go. You can also specify multiple placeholders like $1, $2, $3, and so on, which allows you to use the Tab key to move to the next placeholder position in the expanded text fragment.

Atom Basics

Although Atom is a rather powerful text editor, mastering its basics is not particularly complicated. The commands under the File menu allow you to open a single file or an entire directory. The View | Toggle Tree View command enables the Tree View pane, which shows all the files in the opened directory.

Because Atom supports tabs, you can open multiple files for editing and easily switch between them. If the directory contains a lot of files, you can quickly locate the one you need using the fuzzy search feature: Press Ctrl+T and start typing the name of the file you are looking for, and the matching results appear in the drop-down list. Then, select the desired file to open it.

Although many of Atom's features are aimed at developers, they can also be useful for general text editing. Pressing Ctrl+D selects the current word, for example, and pressing the combination again selects the next occurrence of the word. This way, you can select multiple occurrences of a specific word and replace them in a single action. Some of the other keyboard shortcuts might also come in handy. The Ctrl+L shortcut lets you select the current line, and the Ctrl+Up arrow and Ctrl+Down arrow shortcuts can be used to move the current line up and down.

Atom's bookmarking functionality can be useful when working with long texts, and the editor offers several keyboard shortcuts for managing bookmarks. The Ctrl+Shift+F2 shortcut toggles a bookmark at the current location, and the F2 and Shift+F2 shortcuts jump to the next and the previous bookmarks.

The editor features dozens, if not hundreds, of commands, and remembering them all and their keyboard shortcuts can be a daunting proposition. Fortunately, Atom comes with the Command Palette tool for quick access to all supported commands (Figure 2). Pressing Ctrl+Shift+P evokes the Command Palette, then you can start typing the name of the desired command. Selecting the command you need from the drop-down list of matching results performs the action.

Figure 2: The Command Palette provides an efficient way to find and run commands.

Extending Atom with Packages

Thanks to its modular architecture, you can tailor Atom to your specific needs and extend the editor with the use of packages. The Packages section of the Settings interface makes it possible to install and manage packages without leaving the editor (Figure  3): Just find the desired package, and use the appropriate buttons to install and configure the package. Atom automatically checks for updates and prompts you when newer versions of installed packages are available.

Figure 3: You can install and manage packages directly from within Atom.

The official package repository [4] contains a wealth of packages, including those useful for writing. Word Count [5] is the package you might want to install right from the start. As the name suggests, this simple package adds the word count feature that is essential for all writing professionals. The package shows a word and character count in the status bar.

If you find Atom's interface too busy for your liking, Zen package [6] is right up your alley. It turns Atom into a distraction-free environment by hiding interface elements, including the tree view, the status bar, and the tab bar (Figure 4). You can toggle Zen mode by pressing Shift+F11.

Figure 4: The Zen package turns Atom into a distraction-free writing environment.

The Minimap package [7] adds another creature comfort: a sidebar containing a bird's eye view of the current document. You can use Minimap to move quickly to the desired place in the text by dragging the selection area.

The Project Manager package [8] can come in particularly useful when you work on several projects, each containing multiple files. This package makes it possible to save each session as a separate project and then quickly open projects and switch between them. Once installed, the Project Manager adds a separate entry to the Packages menu. This entry contains commands for saving the current session as a project, toggling between existing projects, and editing projects. Alternatively, you can use the Command Palette, which provides a faster and more efficient way to run the commands. Press Ctrl+Shift+P to evoke the Command Palette, type project, and select the desired command with the Project Manager prefix.

Although the Tasks package [9] won't add any writing-related functionality to Atom, it's perfect for keeping track of your tasks without leaving the editor. The package adds several commands (accessible via the Command Palette) that can apply special formatting to .todo and .taskpaper text files. Selecting the Tasks:Add command adds a new task, and the Tasks:Complete command marks the currently selected task as complete. You can also archive the current task using the Tasks:Archive command and mark it as canceled with the Tasks:Cancel command.

If you need to use Atom to access and edit files on a remote server, the Remote Edit package [10] is your best friend. After installing the package and adding connection profiles, you can use Atom to edit text files stored on remote hosts (Figure  5). Remote Edit features a convenient graphical interface for creating connection profiles, and the package supports the SSH and FTP protocols. Using the available commands, you can establish a connection to a remote host, find the text file you need, and open it for editing.

Figure 5: The Remote Edit package makes it possible to edit text files on a remote server.

Dealing with PDF files usually requires a dedicated PDF viewer. However, you can peruse PDF documents without leaving the convenience of Atom, courtesy of the PDF View package [11]. Based on the excellent PDF.js library, this package lets you open PDF files directly in the editor.

If you use Git for versioning, you'll appreciate the Git History package [12]. As the name suggests, this package shows the history of the current text file and lets you open any of its previous versions (Figure 6). This functionality is rather straightforward: Evoke the Command Palette, type Git History, and select the Show File History command. From the drop-down list, pick the desired version of the file to open it side-by-side with the current text.

Figure 6: The Git History package lets you view the history of a file and open any previous version of that file.

If you run Atom on several machines, configuring the editor and installing packages can quickly become a nuisance. Fortunately, the Sync Settings package [13] provides a solution to this problem. This package lets you store key Atom settings (basic configuration, custom keyboard binding, and a list of installed packages) as a gist on the GitHub Gist service [14]. To make use of this package, you need to sign in to GitHub and create a new personal access token with the gist scope [15]. Then, create a new gist and note its ID (the alphanumeric part of the URL after the user name).

In Atom, open the Settings interface and locate the Sync Settings package using the Filter packages field. Selecting the package opens its settings, where you can enter the gist ID and the token into the appropriate fields. You can then upload Atom settings using the Packages | Synchronize Settings | Upload command (or by using the Command Palette). To import the settings to Atom running on another machine, configure the Sync Settings package as described and use the Packages | Synchronize Settings | Download command (Figure 7).

Figure 7: The Sync Settings package can be used to synchronize Atom settings across multiple installations.

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