installation via terminal

To install the full GUI-capable build on Ubuntu

sudo apt update
sudo apt install emacs -y
emacs --version | | shows the installed Emacs version |'ec1'
sudo apt install emacs-nox -y | | installs a terminal-only build with no GUI/X11 dependencies — the right choice on a headless server or over SSH |'ec2'
emacs -nw <file> | | opens Emacs inside the current terminal ("no window"), even if the GUI build is installed |'ec3'
emacs <file> & | | opens the GUI build in the background, freeing up the terminal |'ec4'

keybinding notation & help

Emacs commands are written as key sequences using two prefixes:
  1. C- means Control. C-x is Ctrl held down while pressing x.
  2. M- means Meta — normally the Alt key (Option on macOS). M-x is Alt held down while pressing x. If Alt isn't available, press and release Esc, then press the key.
A sequence like C-x C-s means: hold Ctrl, press x, release, hold Ctrl again, press s. There is no modal editing here — unlike vim, you are always typing directly into the buffer; commands are reached through Ctrl/Meta chords instead of a separate normal mode.

Emacs is self-documenting: almost every part of it can explain itself from inside a running session.
C-h t | | starts the built-in interactive tutorial — the best first stop for a new user |'ec5'
C-h ? | | opens the top-level help menu, listing every other C-h option |'ec6'
C-h k <key> | | press a keystroke and Emacs describes exactly what command it runs |'ec7'
C-h f <function> | | describes a named command/function, with its own keybindings if any |'ec8'
C-h v <variable> | | describes a configuration variable and its current value |'ec9'
C-h m | | describes the major and minor modes active in the current buffer |'ec10'
C-h b | | lists every keybinding currently active in this buffer |'ec11'
M-x | | execute-extended-command — runs any Emacs command by its full name, with tab completion. Every keybinding in this page is a shortcut for some M-x command |'ec12'
C-g | | cancels/aborts whatever is currently in progress — the universal panic button when a command prompt goes sideways |'ec13'

major & minor modes

Every buffer has exactly one major mode, which defines how it behaves for the kind of content it holds (c++-mode, python-mode, fundamental-mode for plain text). Emacs picks one automatically from the filename or content when you open a file. A buffer can also have any number of minor modes layered on top, each toggling one independent feature on or off (flyspell-mode for spell-checking as you type, line-number-mode to show line numbers). C-h m (above) lists everything active in the current buffer.

opening, saving & exiting

C-x C-f | | find-file — opens a file into a new buffer (creates it if it doesn't exist yet) |'ec14'
C-x C-s | | save-buffer — saves the current buffer back to its file |'ec15'
C-x C-w | | write-file — saves the buffer under a new filename ("save as") |'ec16'
C-x s | | save-some-buffers — asks, one by one, whether to save each modified buffer |'ec17'
C-x C-c | | exits Emacs, prompting to save any unsaved buffers first |'ec18'
C-z | | suspends Emacs back to the shell in a terminal session (or minimizes the window in the GUI build); resume a suspended terminal session with "fg" |'ec19'

cursor movement

C-f / C-b | | move forward/backward one character |'ec20'
M-f / M-b | | move forward/backward one word |'ec21'
C-n / C-p | | move to the next/previous line |'ec22'
C-a / C-e | | move to the beginning/end of the current line |'ec23'
M-a / M-e | | move to the beginning/end of the current sentence |'ec24'
M-{ / M-} | | move backward/forward one paragraph |'ec25'
C-v / M-v | | scroll forward/backward one screen (page down/up) |'ec26'
M-< / M-> | | go to the very beginning/end of the buffer |'ec27'
M-g g | | goto-line — prompts for a line number and jumps there |'ec28'
C-l | | recenters the screen around the cursor, cycling between center/top/bottom on repeat — also useful as a plain screen redraw |'ec29'

editing basics

| | Any printable key you type is inserted directly at the cursor — there's no separate insert mode to enter first. |'ec30'
DEL / Backspace | | delete-backward-char — deletes the character before the cursor |'ec31'
C-d | | delete-char — deletes the character under/after the cursor (forward delete) |'ec32'
M-d | | kill-word — deletes the word forward, saving it to the kill ring |'ec33'
M-DEL | | backward-kill-word — deletes the word backward, saving it to the kill ring |'ec34'
RET | | inserts a newline |'ec35'
C-o | | open-line — inserts a blank line after the cursor without moving the cursor onto it |'ec36'
Tab | | indent-for-tab-command — reindents the current line according to the major mode's rules (not a literal tab character in programming modes) |'ec37'

the kill ring (cut/copy/paste)

Emacs doesn't use a single clipboard slot the way most editors do. Every cut ("kill" in Emacs terms) is pushed onto the kill ring, a ring buffer of past kills you can cycle back through after pasting.
C-k | | kill-line — kills from the cursor to the end of the line. A second C-k at an already-empty end of line kills the newline too, joining the next line up |'ec38'
C-w | | kill-region — kills the selected region (see mark & region below) |'ec39'
M-w | | kill-ring-save — copies the selected region onto the kill ring without deleting it |'ec40'
C-y | | yank — pastes ("yanks") the most recent kill at the cursor |'ec41'
M-y | | yank-pop — immediately after a C-y, replaces the pasted text with an older entry from the kill ring; repeat to keep cycling back |'ec42'
C-M-w | | append-next-kill — makes the next kill command append onto the previous kill-ring entry instead of starting a new one |'ec43'

mark & region

Emacs selects text by dropping an invisible mark at one end and moving the cursor ("point") to the other — the span between them is the region, the argument that C-w, M-w, and many other commands act on.
C-SPC (or C-@) | | set-mark-command — drops the mark at the cursor; any cursor movement after this defines the region |'ec44'
C-x C-x | | exchange-point-and-mark — swaps the cursor and the mark, and reactivates the region — handy for checking both ends of a selection |'ec45'
C-x h | | mark-whole-buffer — selects the entire buffer as the region |'ec46'

search & replace

C-s | | isearch-forward — incremental search; the buffer jumps to the first match as you type each character. Press C-s again to jump to the next match |'ec47'
C-r | | isearch-backward — same, searching toward the beginning of the buffer |'ec48'
RET | | [during isearch] exits the search, leaving the cursor at the current match |'ec49'
C-g | | [during isearch] cancels the search and returns the cursor to where it started |'ec50'
M-% | | query-replace — interactively replaces one string with another, pausing at each match to ask |'ec51'
C-M-% | | query-replace-regexp — same, but the search string is a regular expression |'ec52'
M-x replace-string | | replaces every occurrence in one shot, no per-match confirmation |'ec53'

undo

C-/ (or C-x u, or C-_) | | undo — steps back through the edit history |'ec54'
Stock Emacs has no separate "redo" keybinding. Instead: keep pressing undo to keep undoing. The moment you type any other command, the next undo you press starts undoing the undos themselves — which is how you get back the changes you just undid too far.

buffers & windows

A buffer is Emacs's in-memory copy of a file's contents (or of a scratch area with no file at all). A window is a viewport onto a buffer — the terminal or GUI frame can be split into several windows at once. A frame is a whole OS-level window (only meaningful with the GUI build; in a terminal, one frame fills the terminal).
C-x b | | switch-to-buffer — switch to another open buffer by name, with tab completion |'ec55'
C-x C-b | | list-buffers — opens a list of every open buffer |'ec56'
C-x k | | kill-buffer — closes a buffer |'ec57'
C-x 2 | | split-window-below — splits the current window horizontally, stacking a new one underneath |'ec58'
C-x 3 | | split-window-right — splits the current window vertically, adding a new one to the right |'ec59'
C-x o | | other-window — moves focus to the next window |'ec60'
C-x 1 | | delete-other-windows — expands the focused window to fill the whole frame |'ec61'
C-x 0 | | delete-window — closes the focused window (the buffer itself stays open) |'ec62'
C-x 5 2 | | make-frame-command — opens a new OS-level window (GUI build only) |'ec63'
C-x 5 0 | | delete-frame — closes the current frame (GUI build only) |'ec64'

registers, rectangles & bookmarks

C-x r SPC <letter> | | point-to-register — saves the current cursor position into a named register |'ec65'
C-x r j <letter> | | jump-to-register — jumps back to a position (or inserts text) saved in that register |'ec66'
C-x r s <letter> | | copy-to-register — saves the selected region's text into a register |'ec67'
C-x r i <letter> | | insert-register — inserts the text stored in a register at the cursor |'ec68'
C-x r m | | bookmark-set — unlike a register, a bookmark is named, persistent, and survives restarting Emacs |'ec69'
C-x r b | | bookmark-jump — jumps to a saved bookmark by name |'ec70'
C-x r k | | kill-rectangle — cuts a rectangular block of text spanning multiple lines |'ec71'
C-x r y | | yank-rectangle — pastes a previously killed rectangle |'ec72'
C-x r t | | string-rectangle — replaces every line of a rectangular selection with the text you type |'ec73'

keyboard macros

A keyboard macro is a recorded sequence of keystrokes you can replay on demand — useful for a repetitive edit you'd otherwise do by hand many times.
C-x ( | | start-kbd-macro — starts recording keystrokes |'ec74'
C-x ) | | end-kbd-macro — stops recording |'ec75'
C-x e | | call-last-kbd-macro — replays the last recorded macro once; keep pressing e to repeat it again |'ec76'
C-u <N> C-x e | | replays the macro N times in one go |'ec77'
F3 / F4 | | in most modern Emacs builds, these are bound as convenient aliases for start/end-or-call macro |'ec78'

beyond editing text

Emacs is a Lisp runtime with a text editor built on top, which is why so much of daily development can happen without leaving it.
M-x dired (or C-x d) | | opens a navigable directory listing; files can be opened, renamed, deleted, and marked for batch operations from inside it |'ec79'
M-x shell | | opens an interactive shell inside an Emacs buffer |'ec80'
M-x package-list-packages | | browses and installs third-party packages from configured archives (ELPA by default; MELPA is the most common addition, added via the package-archives variable) |'ec81'
M-: | | eval-expression — evaluates a snippet of Emacs Lisp directly, and shows the result |'ec82'

related topics

vim Cheat Sheet — the other keyboard-driven terminal editor, built around modal editing instead of Ctrl/Meta chords.
nano Cheat Sheet — the lightweight alternative when you just need to make a quick edit and get out.
tmux Cheat Sheet — the terminal multiplexer Emacs is commonly run inside over SSH.
VS Code Cheat Sheet — the mouse-driven alternative, if keyboard-only editing isn't your style.

reference

gnu.org/software/emacs