Emacs
Extensible editor/environment with infinite customization via Emacs Lisp.
Official WebsiteFeatures
Installation
brew install --cask emacsapt install emacspacman -S emacsdnf install emacsWhy 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
# 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 --versionBasic Operations and Key Notation
Emacs key bindings are represented with the following notation:
C-xPress Ctrl + x
M-xPress Meta (Alt/Option) + x
C-x C-sPress Ctrl + x, then Ctrl + s
C-x bPress Ctrl + x, then b (release Ctrl)
# 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 -cFrequently Used Commands
File Operations
| Key | Description |
|---|---|
C-x C-f | Open file |
C-x C-s | Save |
C-x C-w | Save as |
C-x C-c | Exit Emacs |
C-x b | Switch buffer |
C-x k | Close buffer |
Movement and Editing
| Key | Description |
|---|---|
C-f / C-b | Move forward / back one character |
C-n / C-p | Move to next / previous line |
C-a / C-e | Move to beginning / end of line |
M-< / M-> | Move to beginning / end of file |
C-v / M-v | Page down / up |
C-d | Delete character at cursor |
C-k | Delete from cursor to end of line |
C-/ or C-_ | Undo |
Selection and Copy (Region)
| Key | Description |
|---|---|
C-SPC | Set mark (start selection) |
C-w | Cut region |
M-w | Copy region |
C-y | Paste (yank) |
M-y | Cycle through kill ring on paste |
Search and Replace
| Key | Description |
|---|---|
C-s | Forward search |
C-r | Backward search |
M-% | Replace (query replace) |
M-x replace-string | Replace all |
Configuration File
Write Emacs configuration in ~/.emacs.d/init.el or~/.emacs.
;; 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 windowPackage Management (use-package)
use-package is a macro for writing concise Emacs package configuration (built-in in Emacs 29+).
Package Repository Configuration
;; 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 packagesRecommended Package Configuration
;; 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.
* 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
| Key | Description |
|---|---|
TAB | Expand / collapse heading |
M-RET | Create new heading / list item |
C-c C-t | Toggle TODO status |
C-c C-d | Set deadline date |
C-c C-c | Toggle checkbox / execute spreadsheet |
C-c C-e | Export (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/emacsSpacemacs
Choose between Emacs and Vim key bindings. Manage features using a layer system.
git clone https://github.com/syl20bnr/spacemacs ~/.emacs.dPrelude
Improves Emacs defaults while respecting them. For those who want to maintain pure Emacs style.
git clone https://github.com/bbatsov/prelude ~/.emacs.dTips
- •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-xto execute any command by name. Installwhich-keyto also see key bindings. - •If startup is slow, use daemon mode with
emacs --daemonand connect withemacsclientfor speed. - •Vim users can use
evil-modefor 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.