Please see also my (redacted) .emacs.d on github. (As an example of a redaction, I have org-capture templates for the people I commonly meet with to add agenda items for our upcoming meetings.)

What is Emacs?

Emacs is a text editor that's been around since at least the 1980s. Emacs is in many ways the exemplar of GNU software: it was designed to be totally open-source, where you could change anything yourself, much like how the VW Beetle was designed to be easy to maintain.

I was first introduced to Emacs in the mid-1990s when one of my friends told me "there's a text editor that will tell you the sunrise and sunset for the current day if you tell it your latitude and longitude." (This was a big deal prior to the Internet.) Then I learned that Emacs had Eliza the chatbot built-in. Then I learned it played Tower of Hanoi for arbitrary numbers of rings.

I didn't really start to use Emacs until college, when I switched to using FreeBSD as my primary operating system. Different types have tools are designed for different patterns: Windows machines are designed for Microsoft tools like MS Word; FreeBSD was designed to let you run open-source software.

By this point I was fairly deep into Unix systems administration work, both for my jobs/internships and as a Perl programmer. The two main editors at the time were vi and Emacs. I got really good at using vi. However, I wanted to learn more about Emacs. I think I really got into Emacs due to a computer science course that was taught in lisp. I found that (for me) using Emacs and LaTeX to write papers on FreeBSD was not appreciably harder than trying to use Microsoft-compatible tools.

Oh also Emacs is written in Emacs lisp, which is a lisp variant. Everything in Emacs can be controlled via Emacs lisp, including what Emacs does in response to any keystroke you hit. Emacs therefore has great lisp parsing capabilities, which is especially important for helping you wade through matching parentheses.

So I'd say over a period of around 20 years I've learned Emacs in fits and starts. Nowadays I'm actually using it for most types of writing, such as checking my email and creating this web site. My experience fits with the article, "Learn Emacs in Ten Years."

Why Emacs?

I enjoy learning different user interfaces and different ways of approaching work. Emacs is heavily keyboard-dependent and rewards people who invest time in learning to working more effectively. Here are a few things that Emacs can do that are, in my experience, difficult to do in other editing tools:

  • Extensible, e.g. someone created a module emacs-google-this to let you search Google from Emacs.
  • Customizable, e.g. I bound a key command to record a new to-do item. I can type this key command from anywhere in Emacs to record a new to-do item as well as record a link to wherever I am when I record the to-do item.
  • Easy to navigate via the keyboard, e.g. there are key commands to go forward a letter, a word, a sentence, a paragraph, a screen, or more.
  • Easy to "chain" commands, e.g. you can create a macro that goes to the beginning of a line, deletes the first word, then goes to the end of the line, adds a word, and then goes down to the next line. You can then run this command over every line.
  • Many "modes" of domain knowledge for different types of content, e.g. there are many programming language-specific modes, "org-mode" for organizing text and to-do's, several email modes, version control modes, and more. Multiple modes can apply to the same content, e.g. if you are using markdown and also version control.

Configuring Emacs

It's definitely possible to use "vanilla" Emacs, with no configuration. However, it's common for people to create a ~/.emacs file and then later move on to creating a whole ~/.emacs.d configuration directory. Emacs will read these configuration files to figure out what you want Emacs to do that's specific to you. You can see a redacted version of my ~/.emacs.d on github (borwick/emacs.d).

Here are a few things that I've configured Emacs to do. I've written the bulk of my Emacs configuration in a "literate programming" style, where there's text surrounding my configuration to explain it. You can see that via emacs.d/ As a few examples:

  • Prompt me to make sure I really want to quit, when I tell Emacs to quit
  • Turn on specific modes depending on the file extension, e.g. json-mode for .json files
  • Create "capture templates" to let me record new to-dos or other items, and bind these to keyboard commands

Keyboard shortcuts

Emacs uses an incredible number of keyboard shortcuts. It's so many that there's a keyboard shortcut to show you the currently-active keyboard shortcuts (C-h b). Keyboard shortcuts are written as a list of keystrokes with modifier keys:

Modifier Emacs Example What this means
Control C- C-h Control+h key
Shift S- C-S-h Control+shift+h key
Meta M- M-h Meta+h key

What's "Meta"? Meta can be configured, but it's usually ALT on Windows, Option on OS X, and can also be accessed by hitting the Escape key. (For example M-h could be typed as ESC followed by h.)

It's pretty safe to say that if you don't want to learn any keyboard shortcuts, you shouldn't use Emacs.

If you are up for learning keyboard shortcuts, then if you're doing something several times then you may find there's a keyboard shortcut that will help you. Here are a few that I use that are baked into Emacs. (I have added other custom keyboard commands too.)

What I type What it does
M-c Capitalize this word
M-l Lowercase this word
C-a Go to beginning of line
C-e Go to end of line
C-w Cut
M-w Copy
C-y Paste
M-y Replace whatever I pasted last with the previous clipboard content

The commands start to end up like that last example, where if you're from another editing environment you might say, "huh?" In that particular example, Emacs has a thing called the "kill-ring" and it remembers the last many things that you cut or copied; then when you paste you can say "actually I meant the thing before that" with M-y.

Getting started

If you are interested in using Emacs:

  1. Download Emacs
  2. Install Emacs
  3. Run Emacs
  4. Type C-h t. (C-h means "help" and t means "tutorial.")

If you have run the tutorial, some next steps you can try are:

  • editing a file that Emacs natively supports, which includes most programming language files and text files
  • starting a writing project: choose the format you want to use/try:
    • Markdown?
    • LaTeX?
    • org-mode?
    • text?
    • texinfo? (If this is the format you're going to use, you probably shouldn't be reading this page)
  • running M-x customize to customize Emacs
  • creating a ~/.emacs or ~/.emacs.d/init.el file to customize Emacs through code you write
  • trying to add a little new functionality to your existing Emacs environment:
    • adding magit for Git version control
    • looking through list-packages to see other Emacs modules
    • looking through other people's .emacs.d examples
    • looking through the Emacs manual