Distraction-Free Editing with Emacs

In recent years there has been a trend towards distraction-free writing, in which text is typed in a plain, full-screen window without distractions such as a web browser, email client, and notifications. The idea is that the writer can focus on the writing without being interrupted or distracted. New editors with these attributes have been produced for both desktop and mobile devices. The review mentioned in the Tweet to the right looked at nine such editors, ranging in cost from free to $44.99. Usually overlooked in such reviews is the possibility of configuring an existing editor to be distraction free. In this regard there is no better option than Emacs, which is free and trumps all the specialized editors for features.

Here is how to make Emacs distraction free. First, turn off unnecessary screen furniture by putting these lines in your .emacs configuration file:

(scroll-bar-mode 0)    ; Turn off scrollbars.
(tool-bar-mode 0)      ; Turn off toolbars.
(fringe-mode 0)        ; Turn off left and right fringe cols.
(menu-bar-mode 0)      ; Turn off menus.

Then, if you haven’t already done so, select a suitable color scheme by installing an appropriate Emacs theme; see the Emacs Themes site for lots of examples. Finally, type

M-x toggle-frame-full-screen

to make the Emacs window occupy the whole screen. Type it again to revert to the original window size.

Here is how the top left-hand corner of my screen looks as I write this post after carrying out the above steps (everything to the right of what is shown is black). 160110-emacs.jpg

It’s possible to go even further in simplifying the Emacs screen: see the excellent article Emacs, naked by Bastien Guerry.

One of the features that reviews of distraction-free editors look for is word counts. The Emacs command

M-x count-words

shows the number of characters, words, and lines, and there is an Emacs mode wc-mode that gives a constantly updated display of these statistics in the mode line.

Another relevant feature is support for Markdown. Emacs has a Markdown mode, as well as a much more powerful markup language called Org mode (used to write the posts on this blog).

“Distraction free” can also mean focusing on the part of the document you are editing, and this brings me to a final feature that is rarely discussed: narrowing. Narrowing means seeing only the logical unit that you are editing, which could be a paragraph, subsection, section, or a logical unit in a markup language. Emacs can intelligently narrow down to the appropriate unit. I recommend Artur Malabarba’s narrow-or-widen-dwim command. The easiest way to narrow to a paragraph is to mark it as a region with M-x mark-paragraph then type M-x call narrow-or-widen-dwim. Of course, all the Emacs commands beginning M-x above can be assigned to a key and invoked with a single keypress.

One possible objection to Emacs is that it does not run on mobile devices. In fact, there are projects to port Emacs or implement Emacs-like editors, as Googling will reveal. And of course one can always SSH into a remote machine running Emacs.

This entry was posted in Emacs. Bookmark the permalink.

2 Responses to Distraction-Free Editing with Emacs

  1. Juan Pechiar says:

    There’s also [Olivetti mode](https://github.com/rnkn/olivetti) for having comfortable line length centred in the screen.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s