The Complete Emacs Guide. Mastering the World's Most Powerful Editor

1. What Is Emacs?

GNU Emacs is not merely a text editor — it is an extensible, self-documenting, real-time display editor that has been evolving since 1976. At its core, Emacs is a Lisp interpreter with a text-editing interface built on top of it. This means that nearly everything you see in Emacs — every command, every keybinding, every menu — is written in Emacs Lisp (Elisp) and is therefore modifiable at runtime without restarting the editor.

This architecture gives Emacs a unique character: it is simultaneously a code editor, an email client, a calendar, a file manager, a terminal emulator, a web browser, an IRC client, and even a game platform. People joke that Emacs is an operating system masquerading as a text editor, and there is more than a kernel of truth in that.

Emacs follows the philosophy that your tools should adapt to you, not the other way around. If a default behaviour annoys you, you change it. If a feature you want doesn’t exist, you write it. This flexibility comes with a learning curve, but the investment pays dividends across a lifetime of computing.


2. Installation

Linux

On Debian/Ubuntu-based systems:

sudo apt install emacs

On Fedora/RHEL:

sudo dnf install emacs

On Arch Linux:

sudo pacman -S emacs

macOS

Using Homebrew:

brew install --cask emacs

For a native macOS build with better performance, emacs-plus is a popular choice:

brew tap d12frosted/emacs-plus
brew install emacs-plus

Windows

Download the latest binary from the GNU FTP mirror or use winget:

winget install GNU.Emacs

Launching Emacs

  • GUI mode (default): emacs
  • Terminal mode: emacs -nw (no window — runs in the terminal)
  • Quick edit and exit: emacs -nw filename

3. Core Concepts

Before touching keybindings, you need to understand Emacs’s mental model.

Notation

Emacs documentation uses specific shorthand:

Notation Meaning
C-x Hold Control, press x
M-x Hold Meta (Alt/Option), press x
C-M-x Hold Control and Meta, press x
RET Enter / Return key
SPC Spacebar
DEL Backspace

Modes

Every buffer in Emacs has a major mode and zero or more minor modes.

  • Major mode determines the primary behaviour of a buffer. Examples: python-mode, org-mode, dired-mode, markdown-mode. There is exactly one major mode active at a time.
  • Minor modes add supplementary features: auto-save-mode, line-number-mode, flycheck-mode, company-mode. Many minor modes can be active simultaneously.

The current modes are always shown in the mode line at the bottom of each window.

Point and Mark

The point is the cursor position. The mark is an invisible saved position. Together they define a region (a selection). Understanding this is crucial for many editing commands.


4. Essential Keybindings

Survival Keybindings (Learn These First)

Keybinding Action
C-g Cancel any operation (your panic button)
C-x C-f Find (open) a file
C-x C-s Save the current buffer
C-x C-c Quit Emacs
C-x u Undo
C-/ Undo (alternative)
M-x Execute any command by name
Keybinding Action
C-f / C-b Forward / backward one character
M-f / M-b Forward / backward one word
C-n / C-p Next / previous line
C-a / C-e Beginning / end of line
M-a / M-e Beginning / end of sentence
C-v / M-v Scroll down / up a page
M-< / M-> Beginning / end of buffer
M-g g Go to line number

Editing

Keybinding Action
C-d Delete character forward
M-d Delete word forward
C-k Kill (cut) to end of line
C-y Yank (paste)
M-y Cycle through kill ring after yank
C-w Kill region (cut selection)
M-w Copy region
C-t Transpose two characters
M-u / M-l / M-c Upcase / downcase / capitalise word
C-x C-u / C-x C-l Upcase / downcase region

Help System

Keybinding Action
C-h k Describe what a key does
C-h f Describe a function
C-h v Describe a variable
C-h m Describe current major mode
C-h t Open the built-in tutorial
C-h r Open the Emacs manual

The help system is extensive and self-contained. When in doubt, use C-h.


5. Buffers, Windows, and Frames

Emacs uses distinct terminology that differs from other editors.

  • Buffer: In-memory text content (not necessarily tied to a file). Every open file is a buffer, but buffers can also hold messages, REPL output, or directory listings.
  • Window: A pane displaying a buffer. You can split the editor into multiple windows.
  • Frame: The OS-level window. Emacs can have multiple frames.

Buffer Commands

Keybinding Action
C-x b Switch to a buffer by name
C-x C-b List all open buffers
C-x k Kill (close) a buffer
M-x ibuffer Open the powerful interactive buffer manager

Window Commands

Keybinding Action
C-x 2 Split window horizontally (top/bottom)
C-x 3 Split window vertically (side by side)
C-x 1 Delete all other windows (keep current)
C-x 0 Delete current window
C-x o Switch focus to next window
C-x ^ Grow window taller

Frame Commands

Keybinding Action
C-x 5 2 Create a new frame
C-x 5 0 Delete current frame
C-x 5 o Switch to next frame

6. The Minibuffer

The minibuffer is the single-line prompt area at the very bottom of the frame. It is where Emacs asks you questions, where you enter file paths, command names, and search terms. It is deceptively powerful:

  • Press TAB for completion.
  • Press M-p / M-n to cycle through history.
  • Press C-g to abort out of it.

When you use a package like Vertico or Ivy, the minibuffer becomes a rich, interactive fuzzy finder.


7. File Management

C-x C-f    Open a file (creates it if it doesn't exist)
C-x C-s    Save
C-x C-w    Save as (write to a new name)
C-x s      Save all unsaved buffers
C-x C-r    Open file read-only
M-x revert-buffer    Reload file from disk

Emacs supports TRAMP (Transparent Remote Access, Multiple Protocols), which lets you edit files on remote servers over SSH as if they were local:

C-x C-f /ssh:user@server:/path/to/file RET

This is one of Emacs’s killer features — a seamless remote editing experience built right in.


8. Editing Techniques

The Kill Ring

Emacs does not have a single clipboard — it has a kill ring, a circular history of everything you have cut. When you yank (C-y), you get the most recent kill. Press M-y repeatedly to cycle through older entries.

Rectangles

Emacs can operate on rectangular regions of text (columns), not just character streams. This is extremely useful for editing tables or structured data.

Keybinding Action
C-x r k Kill rectangle
C-x r y Yank rectangle
C-x r o Open (insert blank) rectangle
C-x r t Replace rectangle with typed text

Multiple Cursors

Install the multiple-cursors package to edit at many positions simultaneously:

(use-package multiple-cursors
  :bind (("C->" . mc/mark-next-like-this)
         ("C-<" . mc/mark-previous-like-this)
         ("C-c C-<" . mc/mark-all-like-this)))

9. Search and Replace

C-s starts an incremental search forward — the buffer scrolls in real time as you type. C-r searches backward.

  • Press C-s again to find the next match.
  • Press RET to stop at the current match.
  • Press C-g to cancel and return to where you started.

C-M-s starts a regexp search forward. Emacs uses its own regexp dialect, where \( and \) group, \| alternates, and \b is a word boundary.

Query Replace

Keybinding Action
M-% Query replace (confirm each substitution)
C-M-% Query replace with regexp

During a query replace, press y to replace, n to skip, ! to replace all remaining, q to quit.


10. Org Mode

Org mode is a reason unto itself to learn Emacs. It is a plain-text system for notes, to-do lists, project planning, literate programming, and document publishing — all in one.

Basic Org Structure

* Heading Level 1
** Heading Level 2
*** Heading Level 3

- Plain list item
- Another item
  - Nested item

1. Numbered item
2. Another

| Column A | Column B |
|----------+----------|
| Value 1  | Value 2  |

TODO Items

* TODO Write the report
* DONE Send the email
* TODO [#A] High-priority task

Press C-c C-t to cycle a heading through TODO states. Press S-Right / S-Left on a heading to change its state.

Agenda

Org’s agenda collects all your tasks across files:

(setq org-agenda-files '("~/org/work.org" "~/org/personal.org"))

Press C-c a to open the agenda dispatcher.

Code Blocks (Babel)

Org Babel lets you embed and execute code directly in your notes:

#+BEGIN_SRC python
print("Hello from inside Org mode!")
#+END_SRC

Press C-c C-c inside the block to execute it and see the result inline.

Exporting

C-c C-e opens the export dispatcher. You can export to HTML, PDF (via LaTeX), Markdown, plain text, and many other formats.


11. Customisation with init.el

The primary way to customise Emacs is through your init file, located at ~/.emacs.d/init.el (or ~/.config/emacs/init.el on modern systems). This file is Emacs Lisp code that runs at startup.

Basic init.el Structure

;;; init.el --- My Emacs configuration

;; =============================================================
;; APPEARANCE
;; =============================================================

;; Disable the toolbar and menu bar for a cleaner look
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)

;; Show line numbers in all programming modes
(add-hook 'prog-mode-hook #'display-line-numbers-mode)

;; Load a theme
(load-theme 'modus-vivendi t)  ; Built-in dark theme

;; Set font
(set-face-attribute 'default nil :font "JetBrains Mono" :height 140)

;; =============================================================
;; BEHAVIOUR
;; =============================================================

;; Don't litter the filesystem with backup files
(setq backup-directory-alist `(("." . "~/.emacs.d/backups")))

;; Automatically reload files changed on disk
(global-auto-revert-mode 1)

;; Show matching parentheses
(show-paren-mode 1)

;; Replace selected text when you type
(delete-selection-mode 1)

;; Remember cursor position in files
(save-place-mode 1)

;; Save minibuffer history between sessions
(savehist-mode 1)

;; Scroll smoothly instead of jumping half-pages
(setq scroll-conservatively 101)

;; Use spaces, not tabs
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)

;; =============================================================
;; KEYBINDINGS
;; =============================================================

;; Make ESC close things like C-g does
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)

;; Quick access to init.el
(defun my/open-init-file ()
  (interactive)
  (find-file user-init-file))
(global-set-key (kbd "C-c e") #'my/open-init-file)

Useful Variables to Set

;; Don't show the startup splash screen
(setq inhibit-startup-message t)

;; Show column number in the mode line
(column-number-mode 1)

;; Confirm before quitting
(setq confirm-kill-emacs 'yes-or-no-p)

;; Answer yes/no prompts with y/n
(fset 'yes-or-no-p 'y-or-n-p)

;; Keep the cursor away from the very edge of the screen
(setq scroll-margin 8)

;; Set the default fill column (for text wrapping)
(setq-default fill-column 80)

12. Package Management

Built-in: package.el

Emacs ships with package.el. Add package archives and install packages:

(require 'package)
(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)

Then use M-x package-install RET package-name RET to install.

use-package is a macro that makes package configuration declarative, clean, and lazy-loading-friendly. It is built into Emacs 29+.

;; Ensure use-package is available (Emacs < 29)
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)  ; Auto-install packages

Every package in this guide uses use-package syntax.

Alternative: straight.el

straight.el is a functional, reproducible package manager that installs packages directly from Git. It pairs beautifully with use-package:

;; Bootstrap straight.el
(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el"
                         user-emacs-directory)))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

(straight-use-package 'use-package)
(setq straight-use-package-by-default t)

Completion Frameworks

Vertico — a minimal vertical completion UI for the minibuffer:

(use-package vertico
  :init (vertico-mode))

Orderless — fuzzy matching style for completions:

(use-package orderless
  :custom
  (completion-styles '(orderless basic))
  (completion-category-defaults nil))

Marginalia — adds helpful annotations to completions:

(use-package marginalia
  :init (marginalia-mode))

Consult — enhanced search and navigation commands:

(use-package consult
  :bind (("C-s" . consult-line)
         ("C-x b" . consult-buffer)
         ("M-g g" . consult-goto-line)))

Project Management

Projectile — project-aware commands (find file in project, grep in project, etc.):

(use-package projectile
  :init (projectile-mode +1)
  :bind (:map projectile-mode-map
              ("C-c p" . projectile-command-map)))

Git Integration

Magit — widely considered the best Git interface ever created, in any editor:

(use-package magit
  :bind ("C-c g" . magit-status))

With Magit you can stage individual hunks, write commit messages, rebase interactively, manage branches, and browse history — all from within Emacs with a clean, keyboard-driven interface.

Syntax Checking

Flycheck — on-the-fly syntax and lint checking:

(use-package flycheck
  :init (global-flycheck-mode))

Autocompletion

Company — text completion framework (works in any buffer):

(use-package company
  :hook (prog-mode . company-mode)
  :custom
  (company-idle-delay 0.2)
  (company-minimum-prefix-length 2))

Themes

Some of the most popular themes on MELPA:

(use-package doom-themes
  :config (load-theme 'doom-one t))

(use-package catppuccin-theme
  :config (load-theme 'catppuccin t))

(use-package gruvbox-theme
  :config (load-theme 'gruvbox-dark-hard t))

Icons

nerd-icons — adds icon support to the mode line, Dired, and more:

(use-package nerd-icons
  :if (display-graphic-p))

(use-package nerd-icons-dired
  :hook (dired-mode . nerd-icons-dired-mode))

14. Evil Mode: Vim Keybindings in Emacs

If you come from Vim or prefer modal editing, Evil mode gives you Vim’s keybinding model inside Emacs — without losing any Emacs power.

(use-package evil
  :init
  (setq evil-want-integration t)
  (setq evil-want-keybinding nil)
  :config
  (evil-mode 1))

;; Evil-collection extends Evil to many more Emacs modes
(use-package evil-collection
  :after evil
  :config
  (evil-collection-init))

With Evil active, you get Normal, Insert, Visual, and Operator states, full motion commands (w, b, e, gg, G), and all Vim operators (d, c, y, >, <).

General.el provides a clean way to set keybindings in Evil:

(use-package general
  :config
  (general-create-definer my-leader-def
    :keymaps '(normal visual emacs)
    :prefix "SPC")
  (my-leader-def
    "f f" '(find-file :which-key "find file")
    "f r" '(consult-recent-file :which-key "recent files")
    "b b" '(consult-buffer :which-key "switch buffer")
    "g g" '(magit-status :which-key "magit status")
    "p p" '(projectile-switch-project :which-key "switch project")))

15. Emacs as an IDE

Language Server Protocol (LSP)

lsp-mode integrates Emacs with Language Server Protocol servers, giving you IDE features like autocompletion, go-to-definition, find references, inline diagnostics, and refactoring:

(use-package lsp-mode
  :commands lsp
  :hook ((python-mode . lsp)
         (go-mode . lsp)
         (rust-mode . lsp)
         (js-mode . lsp))
  :custom
  (lsp-idle-delay 0.5)
  (lsp-enable-snippet nil))

(use-package lsp-ui
  :commands lsp-ui-mode
  :custom
  (lsp-ui-doc-enable t)
  (lsp-ui-sideline-enable t))

Alternatively, Eglot is Emacs’s built-in LSP client (available since Emacs 29) and is lighter-weight:

(use-package eglot
  :hook ((python-mode . eglot-ensure)
         (go-mode . eglot-ensure)
         (rust-mode . eglot-ensure)))

Tree-sitter

Emacs 29+ ships with built-in tree-sitter support for fast, accurate syntax highlighting and structural navigation:

(use-package treesit-auto
  :config
  (global-treesit-auto-mode))

Terminal Emulation

vterm is the best terminal emulator for Emacs, using a compiled C module for full compatibility:

(use-package vterm
  :bind ("C-c t" . vterm))

16. Dired: The Built-in File Manager

Dired (Directory Editor) is Emacs’s built-in file manager. Open it with C-x d or C-x C-f on a directory.

Basic Dired Commands

Key Action
n / p Move down / up
RET Open file or directory
^ Go to parent directory
d Mark for deletion
m Mark file
u Unmark
U Unmark all
x Execute deletions
R Rename / move
C Copy
+ Create directory
Z Compress / decompress
! Run shell command on file
q Quit Dired

Dired Enhancements

;; Open files with the system default application
(use-package dired-open
  :config
  (setq dired-open-extensions '(("pdf" . "zathura")
                                 ("png" . "feh"))))

;; Navigate directories in a single buffer (like ranger)
(use-package dired-single)

;; Show git status in Dired
(use-package dired-git-info
  :bind (:map dired-mode-map (")" . dired-git-info-mode)))

17. Macros and Automation

Emacs keyboard macros let you record a sequence of keystrokes and replay them.

Keybinding Action
F3 or C-x ( Start recording macro
F4 or C-x ) Stop recording
F4 or C-x e Execute last macro
C-u 10 F4 Execute macro 10 times
C-x C-k n Name the last macro
C-x C-k b Bind named macro to a key

For more complex automation, Emacs Lisp is your friend. Any sequence of Emacs operations can be scripted and bound to a key.


18. Emacs Lisp Basics

Emacs Lisp is the extension language of Emacs. Understanding even a little Elisp dramatically increases your ability to customise your environment.

Basic Syntax

;; This is a comment

;; Setting a variable
(setq my-variable 42)

;; Defining a function
(defun greet (name)
  "Say hello to NAME."
  (message "Hello, %s!" name))

;; Calling the function
(greet "World")

;; Conditional
(if (> my-variable 10)
    (message "Big number")
  (message "Small number"))

;; Lambda (anonymous function)
(mapcar (lambda (x) (* x x)) '(1 2 3 4 5))
;; => (1 4 9 16 25)

Interactive Commands

Any function marked (interactive) can be called with M-x:

(defun my/insert-timestamp ()
  "Insert the current date and time at point."
  (interactive)
  (insert (format-time-string "%Y-%m-%d %H:%M:%S")))

(global-set-key (kbd "C-c d") #'my/insert-timestamp)

Hooks

Hooks let you run code when certain events happen:

;; Run something when entering a mode
(add-hook 'python-mode-hook
          (lambda ()
            (setq tab-width 4)
            (setq python-indent-offset 4)))

;; Run something after saving any file
(add-hook 'after-save-hook
          (lambda ()
            (message "File saved at %s"
                     (format-time-string "%H:%M:%S"))))

Evaluating Elisp

You can evaluate Elisp expressions at any time:

  • C-x C-e — evaluate the expression before point
  • M-x eval-buffer — evaluate the entire buffer
  • M-x ielm — open an interactive Elisp REPL
  • M-: — evaluate a one-off expression in the minibuffer

19. Tips, Tricks, and Workflow Advice

Use which-key

which-key shows you available keybindings in a popup after you press a prefix key, making discovery much easier:

(use-package which-key
  :init (which-key-mode)
  :custom (which-key-idle-delay 0.5))

Learn the Tutorial First

Spend 30 minutes on C-h t (the built-in tutorial) before doing anything else. It covers the fundamentals interactively.

Don’t Remap Everything at Once

It is tempting to install a massive configuration framework (like Doom Emacs or Spacemacs) immediately. These are excellent, but starting with a minimal init.el and adding things one at a time teaches you why each piece exists.

Use Emacs Distributions for a Head Start

If you want a batteries-included experience:

  • Doom Emacs (github.com/doomemacs/doomemacs) — fast, opinionated, Evil-centric
  • Spacemacs (spacemacs.org) — heavily layered, supports both Vim and Emacs styles
  • Prelude (github.com/bbatsov/prelude) — more conservative, closer to vanilla Emacs

Master C-x C-e and the Scratch Buffer

The *scratch* buffer is a Lisp playground that opens at startup. Use it to test Elisp snippets. Evaluate expressions with C-x C-e. This fast feedback loop is the heart of Emacs customisation.

Bookmark Frequently Used Files and Positions

C-x r m    Set a bookmark
C-x r b    Jump to a bookmark
C-x r l    List all bookmarks

Use register for Quick Copy-Paste

C-x r s r    Save region to register r
C-x r i r    Insert register r at point

Profile Your Startup Time

Slow startup? Use M-x emacs-init-time to check total time, and the esup package to profile which packages are slow.

Read the Source

In Emacs, you can always jump to the source code of any function with M-. or M-x find-function. This is invaluable for understanding what a command actually does and for writing your own extensions.


Conclusion

Emacs is not a tool you master in a week — it is a tool you grow with over years. Start with the basics, get comfortable with navigation and editing, then begin layering in customisations that match your workflow. Every hour invested in learning Emacs compounds: the editor reshapes itself around your habits and preferences until it becomes a seamless extension of your thinking.

The community is active, the documentation is exceptional, and the ecosystem of packages on MELPA is vast. Whether you use it as a minimal distraction-free writing environment, a heavyweight polyglot IDE, an Org mode life-management system, or all three simultaneously — Emacs will meet you where you are.

Welcome to the church of infinite extensibility.

Get the Complete Guide: The Complete Emacs Guide. Mastering the World's Most Powerful Editor

Prefer to read offline? Get the complete PDF, ePub, and source code bundle.

Buy Now for $19

Includes PDF, ePub, and full source code bundle. Payments securely processed via Gumroad.