Terminal GuideTerminal Guide
emacs icon

Emacs

Text Editors
macOSLinuxWindows
C/Lisp

Extensible editor/environment with infinite customization via Emacs Lisp.

Official Website

Features

Emacs LispOrg ModeMagitPackage Manager

Installation

Homebrew
brew install --cask emacs
APT (Debian/Ubuntu)
apt install emacs
Pacman (Arch)
pacman -S emacs
DNF (Fedora)
dnf install emacs

Why Use Emacs?

Emacs was born in 1976 and continues to evolve as a "programmable platform" that goes beyond a simple text editor. Its greatest feature is infinite extensibility through Emacs Lisp.

Lisp Extensibility

Implement anything with Emacs Lisp. Not just editor features, but also email, IRC, browsers, and more.

Org Mode

The most powerful outlining tool. Supports notes, TODO management, document creation, spreadsheets, and presentations.

Unified Environment

Complete all work within Emacs. Coding, Git, terminal, and documents in one environment.

Extensive Packages

Thousands of packages in MELPA, ELPA, and GNU ELPA. A rich ecosystem built over 40+ years of history.

Installation

Installation
# macOS (Homebrew) - GUI version
brew install --cask emacs

# macOS (Homebrew) - Terminal version
brew install emacs

# Ubuntu/Debian
sudo apt install emacs

# Ubuntu (latest - Snap)
sudo snap install emacs --classic

# Fedora
sudo dnf install emacs

# Arch Linux
sudo pacman -S emacs

# Windows (Chocolatey)
choco install emacs

# Windows (Scoop)
scoop install emacs

# Check version
emacs --version

Basic Operations and Key Notation

Emacs key bindings are represented with the following notation:

C-x

Press Ctrl + x

M-x

Press Meta (Alt/Option) + x

C-x C-s

Press Ctrl + x, then Ctrl + s

C-x b

Press Ctrl + x, then b (release Ctrl)

Basic Operations
# Start Emacs
emacs filename.txt

# Start in terminal mode
emacs -nw filename.txt

# Skip configuration on startup
emacs -Q

# Start in daemon mode
emacs --daemon

# Connect to daemon
emacsclient -c

Frequently Used Commands

File Operations

KeyDescription
C-x C-fOpen file
C-x C-sSave
C-x C-wSave as
C-x C-cExit Emacs
C-x bSwitch buffer
C-x kClose buffer

Movement and Editing

KeyDescription
C-f / C-bMove forward / back one character
C-n / C-pMove to next / previous line
C-a / C-eMove to beginning / end of line
M-< / M->Move to beginning / end of file
C-v / M-vPage down / up
C-dDelete character at cursor
C-kDelete from cursor to end of line
C-/ or C-_Undo

Selection and Copy (Region)

KeyDescription
C-SPCSet mark (start selection)
C-wCut region
M-wCopy region
C-yPaste (yank)
M-yCycle through kill ring on paste

Search and Replace

KeyDescription
C-sForward search
C-rBackward search
M-%Replace (query replace)
M-x replace-stringReplace all

Configuration File

Write Emacs configuration in ~/.emacs.d/init.el or~/.emacs.

~/.emacs.d/init.el
;; Basic settings
(setq inhibit-startup-message t)     ; Hide startup screen
(setq initial-scratch-message nil)   ; Clear scratch buffer message

;; UI settings
(tool-bar-mode -1)                    ; Hide toolbar
(menu-bar-mode -1)                    ; Hide menu bar
(scroll-bar-mode -1)                  ; Hide scrollbar
(global-display-line-numbers-mode 1) ; Show line numbers
(column-number-mode 1)               ; Show column number
(show-paren-mode 1)                  ; Highlight matching brackets

;; Font and appearance
(set-face-attribute 'default nil :height 140)  ; Font size
(load-theme 'modus-vivendi t)                  ; Theme (built-in Emacs 28+)

;; Indentation settings
(setq-default indent-tabs-mode nil)  ; Use spaces instead of tabs
(setq-default tab-width 2)           ; Tab width

;; Backup settings
(setq backup-directory-alist '(("." . "~/.emacs.d/backups")))
(setq auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save/" t)))

;; UTF-8 settings
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)

;; Use y/n instead of yes/no
(defalias 'yes-or-no-p 'y-or-n-p)

;; Auto save
(auto-save-visited-mode 1)

;; Track recently opened files
(recentf-mode 1)
(setq recentf-max-menu-items 25)
(global-set-key (kbd "C-x C-r") 'recentf-open-files)

;; Clipboard integration
(setq select-enable-clipboard t)

;; Custom keybindings
(global-set-key (kbd "M-o") 'other-window)  ; Switch window

Package Management (use-package)

use-package is a macro for writing concise Emacs package configuration (built-in in Emacs 29+).

Package Repository Configuration

~/.emacs.d/init.el
;; Package repository settings
(require 'package)
(setq package-archives
      '(("melpa" . "https://melpa.org/packages/")
        ("gnu" . "https://elpa.gnu.org/packages/")
        ("nongnu" . "https://elpa.nongnu.org/nongnu/")))
(package-initialize)

;; Install use-package (for Emacs 28 and earlier)
(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

Recommended Package Configuration

~/.emacs.d/init.el
;; Color scheme
(use-package doom-themes
  :config
  (load-theme 'doom-one t))

;; Mode line
(use-package doom-modeline
  :init (doom-modeline-mode 1))

;; File explorer
(use-package treemacs
  :bind
  ("C-c t" . treemacs))

;; Completion framework
(use-package vertico
  :init (vertico-mode))

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

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

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

;; Git integration (Magit)
(use-package magit
  :bind ("C-x g" . magit-status))

;; Enhanced syntax highlighting
(use-package tree-sitter
  :config
  (global-tree-sitter-mode)
  (add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode))

(use-package tree-sitter-langs)

;; LSP support
(use-package eglot
  :hook
  ((python-mode . eglot-ensure)
   (typescript-mode . eglot-ensure)
   (rust-mode . eglot-ensure)))

;; Auto-completion
(use-package corfu
  :init (global-corfu-mode)
  :custom
  (corfu-auto t)
  (corfu-auto-delay 0.2))

;; Auto-pair brackets
(use-package smartparens
  :config
  (smartparens-global-mode t))

;; Comment toggle
(use-package evil-nerd-commenter
  :bind ("M-;" . evilnc-comment-or-uncomment-lines))

;; which-key (keybinding help)
(use-package which-key
  :init (which-key-mode)
  :config
  (setq which-key-idle-delay 0.5))

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

Org Mode

Org mode is one of Emacs' most powerful features. Manage notes, TODOs, and document creation all in one format.

example.org
* Project Management
** TODO Task 1
   DEADLINE: <2024-01-15>
   - [ ] Subtask 1
   - [X] Subtask 2 (completed)

** DONE Completed Task
   CLOSED: [2024-01-10]

* Notes
  You can write plain text here.

  #+BEGIN_SRC python
  def hello():
      print("Hello, Org mode!")
  #+END_SRC

* Spreadsheet
  | Item   | Qty  | Price | Total |
  |--------+------+-------+-------|
  | Apple  |    3 |   100 |   300 |
  | Orange |    5 |    80 |   400 |
  |--------+------+-------+-------|
  | Total  |      |       |   700 |
  #+TBLFM: $4=$2*$3::@5$4=vsum(@2..@4)

Org Mode Key Bindings

KeyDescription
TABExpand / collapse heading
M-RETCreate new heading / list item
C-c C-tToggle TODO status
C-c C-dSet deadline date
C-c C-cToggle checkbox / execute spreadsheet
C-c C-eExport (HTML, PDF, etc.)

Emacs Distributions

Pre-configured Emacs package sets. Recommended if you don't have time to configure from scratch.

Doom Emacs

Vim-like key bindings, fast startup, modern UI. Popular choice for Vim users transitioning to Emacs.

git clone https://github.com/doomemacs/doomemacs ~/.config/emacs

Spacemacs

Choose between Emacs and Vim key bindings. Manage features using a layer system.

git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d

Prelude

Improves Emacs defaults while respecting them. For those who want to maintain pure Emacs style.

git clone https://github.com/bbatsov/prelude ~/.emacs.d

Tips

  • First, run the tutorial with C-h t. You'll learn the basics in about 30 minutes.
  • After C-h k, press a key to see what it does.
  • Use M-x to execute any command by name. Install which-key to also see key bindings.
  • If startup is slow, use daemon mode with emacs --daemon and connect with emacsclient for speed.
  • Vim users can use evil-mode for Vim key bindings. Doom Emacs has Evil enabled by default.
  • Magit is considered the best Git interface. Try it with C-x g.
  • After changing configuration, apply changes immediately with M-x eval-buffer. No restart needed.
Written by Dai AokiPublished: 2026-01-20

Related Articles

Explore More