GitHub's configurable editor

Hacker Kitchen

© Lead Image © serezniy, 123RF.com

© Lead Image © serezniy, 123RF.com

Article from Issue 178/2015
Author(s):

The Atom code editor from GitHub is a highly configurable free application. Just one year old, even at this early stage, the mix looks very promising.

When GitHub announced Atom [1] in June 2014, many observers sighed: Does the world really need yet another text editor? Well, the makers of GitHub are convinced it does. Sublime Text [2] might be convenient, but it is not genuinely configurable. On the other hand, Emacs and Vi are highly configurable, but not exactly convenient for the uninitiated.

The makers of GitHub know pretty well how the open source world ticks, and they have gotten very few things wrong thus far. Atom is no exception. Vi and Emacs only work as sustainably and well as they do because they are both open and have a large community. Consequently, GitHub plans to be involved long-term with the editor. Atom 1.0 was released on June 25, 2015, under an MIT license, but that does not rule out GitHub offering an enterprise variant of the editor at some time.

Atom Model

Atom is intended to help developers program desktop and web applications across multiple platforms. The software comes with syntax highlighting for various programming languages – from JavaScript, through Perl and Python, up to C, C++, or Java. At the end of the day, Atom is a variant of the Chromium browser, and the windows are no more than locally rendered web pages, from which the content can access the Node.js API.

Atom consists of an easily manageable core (Atom Core), with most other components available as Atom packages managed by the Atom Package Manager (APM). The core and the packages run on the Electron framework [3], which was previously known as the Atom Shell. The Atom Shell takes care of automatic updates, includes a Windows installer, creates crash reports, and delivers notifications. The functions are accessible through JavaScript APIs.

For simplicity's sake, the developers use and recommend CoffeeScript instead of JavaScript for working with Atom and Less as a replacement for CSS. That said, the editor can also be extended to include JavaScript and CSS.

Control Panel

After the installation – which could be somewhat less complex (see the box "Installing Atom") – developers are taken to a graphical interface (Figure 1). It comprises various panes that can be zoomed and rearranged as needed. The individual files in which a developer works are known as "buffers" in Atom-speak.

Installing Atom

Installation on Ubuntu 14.04 with an LXDE desktop involved some overhead, mainly attributable to the Node.js environment that Atom needs. Prebuilt packages exist, but if you want to compile the software yourself, you first need to install the matching files:

sudo apt-get install build-essential git libgnome-keyring-dev fakeroot gconf-service libnss3

The next step is to download the latest version of Node.js, which is available on NodeSource.com [4]:

curl -sL https://deb.nodesource.com/setup | sudo bash -

The command sequence basically fetches a setup script for the current node version and runs it with root privileges. More cautious users will probably want to insert more after the pipe to watch the script run. The command

sudo apt-get install -y nodejs

installs the latest variant of the framework – if it runs without any complaints.

If the which node command does not show any results, the binary below /usr/bin/ that Atom is looking for might be named nodejs instead of node. The command

sudo update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10

provides a remedy. The next set of commands clones the Atom repository on GitHub and then checks out the latest Atom release from the atom directory:

git clone https://github.com/atom/atom
cd atom
git fetch -p
git checkout $(git describe --tags `git rev-list  --tags --max-count=1`)

Finally, you need to run the build script and then launch the JavaScript Task Runner Grunt [5] to install the executable atom file and the apm package manager in /usr/local/bin. Incidentally, you can also use Grunt to create a Debian package via script/grunt mkdeb.

Figure 1: Atom comprises flexibly arranged multiple panes.

After starting Atom, you find the directory tree for the current project in the left-hand pane. The code belongs in the large field in the middle. Pressing F11 takes you to full-screen mode; Atom opens the settings as additional tabs when you press Ctrl+, (Ctrl+<comma>), or when you select Edit | Preferences.

If you are uncertain how to proceed, you can tell the editor to show all available commands with Ctrl+Shift+P. A useful Flight Manual is also available online [6].

In the Reactor

Although the editor is still a fairly young project, it already comes with a number of useful features. To indent one or multiple lines of code, you select the text and pressing Tab. Shift+Tab moves the block of code to the left.

Auto-completion is also implemented, and the developers promise to expand this in the future. Right now, you can press Ctrl+Space to enable the feature and display alternatives to the element underneath the cursor.

When you access the settings (Ctrl+,) and mark the Soft Wrap checkbox below the Editor Settings section, the editor wraps the line at the end of the screen. Checking Soft Wrap At Preferred Line Length wraps the code after n characters. The line break border is marked by an invisible line; by default the length is 80 characters, but you can change this in the Preferred Line Length text box in the same section.

If you enable the Soft Tabs option, the editor automatically converts tabs to space characters; you can even define the number of space characters in the settings (Tab Length drop-down box).

Folding means hiding blocks of code (e.g., functions, loops) to simplify your view of the code. Folding is accomplished either with the small triangles that appear when mousing over the gutter or with Alt+Ctrl+[(fold) or Alt+Ctrl+] (unfold). The triangles are sometimes difficult to hit, causing the editor to jump suddenly to other snippets of code.

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

  • Workspace: Atom Editor

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

  • Clojure

    Clojure looks like Lisp and runs wherever Java is installed. Practical tools and sophisticated libraries provide the underpinnings for rapid development of modern web applications.

  • Custom Keybindings in the Atom Editor
  • JavaScript Alternatives

    JavaScript is the stuff of which many interactive web clients is made, but it comes with a fair amount of historical ballast. The creators of four alternative scripting languages seek to ditch the ballast.

  • GitHub with hub

    The handy hub command-line tool lets you manage your GitHub repository from a terminal window, which can make it easier to automate repetitive tasks.

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News