This article describes getting started with Emacs - installing the software and the basic principles on how to operate the software.

Getting Started with Emacs

Peter Prevos

Peter Prevos |

1103 words | 6 minutes

Share this content

Emacs has a reputation for being hard to use. This article crushes that myth and describes getting started with Emacs without any configuration. Once you understand the basic principles, you will soon play the software like a virtuoso plays the piano.

Emacs will take some getting used to because the first version of the software was released almost forty years ago. Although Emacs is one of the oldest continuously developed software packages, it has evolved into a versatile contemporary computing system. But, just like biological organisms have vestigial features that originated in the distant past, Emacs also has some quirky features and terminology that stem from its long history. This article guides you through the basics of using Emacs to get you started by explaining the principles.

This article is an abridged chapter of Emacs Writing Studio (EWS) — a configuration, website and book that explains how to use Emacs to undertake research and write and publish articles, books, and websites. Emacs Writing Studio is available as an e-book with expanded content from your favourite retailer.

Emacs Writing Studio

Emacs Writing Studio

A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.

The source files of the book and EWS configuration are also freely available on GitHub.

Installing Emacs

The first point of call is to install Emacs on your computer. The Emacs computing environment works on almost all operating systems, but best integrates with GNU / Linux. You can install it on your Linux distribution with the relevant package manager. If you use another OS, follow the links below:

The EWS configuration is independent of your operating system.

This video by Marcus Birkenkrahe provides a succinct overview of installing Emacs on Windows or MacOS.

Emacs is also an interface to various other free software packages for such tasks as checking spelling, read PDF files or typesetting and formatting (e)books. The EWS GitHub repository contains a list of these programs and their function.

Getting Started with Emacs

Now that you have cleared the first hurdle, it is time to open Emacs and look around. When you first start Emacs, you see a splash screen with links to help files. Click on the link to read the tutorial, or press the q button to remove the screen and keep reading this article.

The Emacs splash screen.
The Emacs splash screen (Emacs 29.1).

Pressing q is the standard method to close (kill) read-only screens in Emacs. When the splash screen closes, you enter the ’scratch buffer’, which you can use for temporary notes. Emacs does not save the content of the scratch buffer, so don’t start writing your dissertation just yet.

Emacs has a mouse-driven menu system, with drop-down menus on the top of the screen. Most users ignore this convenience and rely on keyboard-driven instructions. There is no real agreement on whether using a keyboard or a mouse is most efficient. What is clear is that regularly moving your hands between the keyboard and the mouse can be annoying and impede your workflow. When you misspell a word in most software, you move your hand from the keyboard to the mouse, click on the offending word and select the desired spelling. In Emacs, you use one keystroke and the misspelled word automatically changes to the most likely correct version, and you keep on writing.

One advantage of the menu system is that it helps discovering functionality in Emacs, but you don't need a mouse for this. Just press F10 and use the arrow keys to find what you need.

Emacs is mostly written in the Emacs Lisp (Elisp) language, which means that every action runs an Elisp function. Most functions are only for internal processes, but the user can call some functions (the commands) interactively. So every command is a function, but not every function is a command.

The default way to activate commands is by typing ALT-x and then the name of the command and the enter key. For example type ALT-x tetris ENTER to play tetris. Don't get too distracted, just press q three times to exit the game.

Typing the full function name every time is too much work for us Emacs users who seek ultimate efficiency. The minibuffer completion system helps you to find the command you seek. In standard Emacs, that would be ALT-x tet TAB ENTER. But that method is not on the efficiency frontier. To meet this demand, Emacs uses keyboard shortcuts.

Working with the keyboard

Emacs is a keyboard-driven system. You can use the mouse, but you;ll find that there is no need to remove your hand from the keyboard. The standard computer keyboard has five types of keys: alphanumeric / punctuation, editing, function, escape key, and modifier keys.

Alphanumeric and punctuation keys activate the self-insert function, which adds text to the computer’s memory and displays it on the screen. The editing keys, such as arrow keys, page up and down, delete, backspace, enter and tab, do what it says on their label. These are the only keys you need to writing prose, but we like to do more than insert text.

Function and multimedia keys perform specified tasks. For example, pressing F10 in Emacs show the menu bar. Multimedia keys activate predefined tasks, such as increasing the screen brightness or playing music.

The escape key is the most potent key on the board. Like Dorothy’s Ruby Slippers in the Wizard of Oz, this key gets you out of trouble by clicking it three times.

These keys cover about 100 options, but more are needed to manage the thousands of possible commands you might want your computer to perform. The modifier keys on a modern PC or Apple keyboard are shift, control, alt/option and windows/command. Some programmable keyboards might have additional modifier keys, such as Fn. Modifier keys have no effect when pressed by themselves. As the name suggests, these keys modify other keys when pressed simultaneously. In Emacs vocabulary, these are called chords.

Emacs documentation uses a special notation for key chords. Some of the Emacs terminology for modifier keys stems from a time when the current standard keyboard layout did not yet exist. What we now call the Alt key used to be the Meta key. What was the Super key in the olden days is now the Windows key on PC keyboards. The image below shows an old Space-Cadet keyboard with now non-existing modifier keys.

Space-cadet keyboard
Symbolics LM-2 Lisp machine space-cadet keyboard.

Emacs documentation uses abbreviations, such as C-a, which stands for the Control and a keys, or M-a, which stands for Alt-a. Each modifier key has its own letter, as shown in the table below. The dash indicates that the keys are pressed while keeping the modifier key down. You can combine modifier keys, occasionally leading to awkward combinations, such as C-M-S a (Control, Alt and Shift a), which requires the nimble fingers of a sleight-of-hand artist to execute smoothly. The shift modifier is often not mentioned in Emacs notation, C-M A is the same as C-M-S a.

The most critical chord is C-g (keyboard-quit), which cancels a partially typed command or one still running. This command can quit running functions, unlike the triple escape key.

The Windows key on PC keyboards is mapped to the old Super key. Your operating system uses Chords with this key, so Emacs does not use this modifier by default. Lastly, the Hyper key is a leftover from the old keyboards.

Modifier Example Function
Shift S-8 * sign on US keyboard
Control C-e End of line
Alt M-d Delete (kill) word
Windows s- Used by the operating system
Hyper H- Not mapped to regular keys

These modifier keys provide thousands of possible key chords to instruct Emacs. But wait, there is more. Emacs also uses prefix keys. When you press these, the system will wait for further input. For example, C-x C-f means that you first press Control and x and then Control and f, the default sequence for finding a file to open with the find-file function. The standard prefix keys are:

  • C-x: Mostly used for built-in Emacs commands
  • C-c: Mostly used by packages
  • C-h: Help functions
  • M-x: Execute commands

This means that the standard Common User Access keyboard shortcuts for cutting text (Ctrl+x) does not work in Emacs.

If you want to find out which command relates to a specific shortcut, then use C-h k and enter the key sequence to see what it is bound to for the mode you currently use. If you want to read the Emacs tutorial, the use C-h t.

Two more prefix keys need mentioning. Lots of commands have alternative states, which means that they can do things in different ways. You activate an alternative state by adding C-u before the regular key-chord.

Lastly, adding a number after Control or Alt repeats the next keystroke. For example M-80 * adds eighty asterisks to your text.

You can change how a keyboard behaves at three levels. Some high-end keyboards are programmable and let you define the output of each key. You could map the right control key as the Hyper key so you can use it in key chords. At the second level, your operating system interprets the input from the keyboard. In Windows, s-E opens the file explorer, but you can erase this binding so that it becomes available in Emacs. Each operating system has its own methods to change keyboard maps (keymaps). Some experienced Emacs users remap the caps lock key to act as the control key to make it easier to use.

Last but not least, you can define keys within Emacs itself. Some people don’t like the Emacs defaults because it requires frequent use of the ALT and Control keys. These people suggest that repetitive use of these keys causes a strain injury, the dreaded’ Emacs pinky’. Several packages, such as Evil Mode or Viper mode, exist within the Emacs ecosystem that changes the default keybindings to a different model. Emacs Writing Studio follows the standard conventions.

You might be dazzled by this detailed description of how Emacs uses the keyboard. Don’t worry about it for now. You will gradually understand its intricacies and eventually drive the system like a virtuoso.

Modes

Emacs is a versatile tool that accomplishes the different tasks it is capable of through the use of major and minor modes.

A major mode determines the main functionality for an open buffer. Each buffer has at least one major mode and each major mode has its own functionality and key bindings. The articles on this website mainly describe how to use Org mode.

A major mode is like opening an app within the Emacs environment. For example, Org mode provides a task management system and publication tools. Artist mode is a quirky tool in Emacs to create plain text drawings with the mouse and keyboard. Other common plain text writing major modes are plain text, Markdown and Fountain. All major modes provide specialise functions for working with these text formats. All major modes share the same underlying Emacs functionality, such as copying and pasting (killing and yanking).

Minor modes provide additional functionality, such as spell-checking, text completion or displaying line numbers. A minor mode is an auxiliary program that enhances the functionality of a major mode. While each buffer has only one major mode, a buffer can have one or more active minor modes. A minor mode can also apply to the whole Emacs session.

Each mode defines how a buffer displays text. For example, each heading level in Org mode has a different colour (depending on your theme). The different colours and fonts help finding your way around the text. However, how the text looks on the screen differs from how it will look when you print it or export it to a PDF of another format. This is a What you See is What You Mean approach, which this article explains in more detail.

Emacs automatically selects the relevant major mode using the extension of the file and displays it in the mode line below each buffer. Minor modes have to be enabled explicitly on top of a major mode.

The available keyboard shortcuts depend on the major and minor modes that are active at the time. Each mode can have its own keymap. Some keymaps are global and apply to the whole of Emacs, other maps are specific to a mode. Some shortcuts remain the same for all modes (such as M-u, which converts a word to uppercase), unless a mode overrides this binding. Packages can change or add shortcuts, depending on the required functionality. So a shortcut like C c c-c is used by different modes for different actions, depending on the context it is used.

If you are lost and like to see all possible keyboard shortcuts for the active buffer (screen), call C-h b to view a list of all available shortcuts. Note that some shortcuts can relate to a specific mode and will thus only work when the mode is active.

Frames and Windows

When you open Emacs, the software runs within a frame. In most operating systems, a frame is called a window. To confuse matters further, you can divide an Emacs frame into windows. You can also open multiple frames on a desktop, for example, one on each monitor.

By default, a frame has one window. You can duplicate the current window horizontally or vertically by pressing C-x 2 or C-x 3 (split-window-below and split-window-right). The C-x 0 shortcut (delete-window) removes your current window, and C-x 1 removes all other windows (delete-other-windows), so you work in the full frame again.

When splitting a window, the same buffer can appear on both sides, each with point at a different location in the text. Using M-x follow-mode flows the text so it becomes like a two-column document. This function toggles the follow function as a minor mode, so you can switch it on and off with the same function.

To move between windows, use the C-x o shortcut (other-window).

The bottom of each window has a mode line, and the bottom of the frame contains the mini buffer. The mode line provides information, such as the open file name, current line number and other helpful information. The mini buffer is where Emacs provides feedback or seeks your input.

Emacs frame with three windows.
Emacs frame with three windows.

Buffers

A buffer holds the text that is displayed in a window. Buffers can also contain a user interface or output from functions. The name of the buffer or its associated file is shown in the status bar at the bottom of the window. Special buffers, such as *Messages* start with an asterisk. This buffer shows the output of any commands you run.

You can have multiple buffers open at the same time so that you can easily switch between buffers. Emacs is highly stable and some Emacs users have hundreds of open buffers as they rarely need to restart the program. The C-x b shortcut (switch-to-buffer) lets you select another buffer to move to.

With the C-x left and C-x right key sequences (previous-buffer and next-buffer), you can move between buffers in chronological activation order.

Files

Most buffers, except those surrounded by an asterisk, are linked to a file. Like office software, you are working on the version in memory (the buffer), and the previous version is on disk (the file). Emacs works precisely the same way.

Opening files in Emacs is called visiting a file. You first need to find it with the find-file function (C-x C-f) to visit a file. Emacs will open the file and display the contents in the buffer. Emacs will create a new file when you type a name that does not yet exist. If you open a directory, Emacs will show the contents of that directory in the file manager.

Emacs will ask you to nominate a file or folder in the mini buffer. When you hit the TAB button twice, all the available files and folders appear in the mini buffer. To complete the file name, start typing the filename and hit TAB again.

After you complete your edits, C-x C-s (save-buffer) saves your buffer. To save all open buffers, press C-x s (save-some-buffers) and follow the prompts in the minibuffer at the bottom of the screen. To save a buffer under a new name, you can use C-x C-w.

Keystroke Function Description
C-x C-f find-file Find (open) a file
C-x C-s save-buffer Save the current buffer to its file
C-x s save-some-buffers Save all open buffers (with confirmation)
C-x C-w write-file Write current buffer to a file (Save as)

Exiting Emacs

After your first practice round, it is time to close (kill) Emacs. The C-x C-c kills the Emacs session, checking for unsaved buffers first (save-buffers-kill-terminal).

Learn more

This article only discussed the basic principles of using Emacs. If you like to know more, then I encourage you to follow the built-in Emacs tutorial, which you activate with C-h t.

There are many great YouTube videos that explain how to use Emacs. The video below by David Williamson provides a detailed introduction into how to use Emacs. The blog posts and YouTube videos by Protesilaos Stavrou also provide useful insights.

The Absolute Beginner's Guide to Emacs (System Crafters).

Emacs Writing Studio

If you like to support my work, then please purchase the Emacs Writing Studio book.

Emacs Writing Studio

Emacs Writing Studio

A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.

You can find the source files for the book and the latest configuration files on GitHub:

Emacs is a malleable system, so everybody will have their personal preferences. Any article on how to use Emacs is thus opinionated. If you have a different way of doing things, please complete the contact form to send me an email or contact me on social media.

You can do a lot with Emacs without any configuration, but you will need to configure the system to make it behave how you want it to. The next article introduces the principles of configuring Emacs to convert it into your own writing studio.

Share this content

You might also enjoy reading these articles

Writing Prose with Emacs

Exploring Your Ideas With the Denote-Explore Package

Reading eBooks with Emacs