Main source is Absolute Beginners Guide to
Emacs
with pictures and key bindings, good plain language overview
Use modeline to check place in file: <file> line number:column
top/bot/all/xx%
Top first line is visible
Bot last line is visible
All first and last line are visible
45% relative position in the file
Format is same as vim ruler (in vim :help ruler
)
Name Shortcuts Run any command M-x Run commands relevant to buffer modes M-S-X (M-X) Find / Open file find-file Save buffer C-x C-s Help C-h C-h Quit partial command C-g Exit emacs C-x C-c Switch buffers C-x b Switch buffers: List Buffers C-x C-b Switch buffers: Cycle through buffers C-x right , C-x left Quit read only buffer q Personal and common major mode leader key C-c Reload screen, mode (many modes like magit, dashboard) g
Name Shortcuts proced: htop equivalent, list system processes and act on them proced proced: Mark m Restart Emacs restart-emacs
Name Shortcuts Update all packages auto-package-update-now Update all straight installed packages straight-pull-all
Name Shortcuts New frame (window) C-x 5 2 Close frame (window) C-x 5 0 Speedbar (like file, buffer explorer) speedbar
Name Shortcuts Split window horizontally C-x 2 Split window vertically C-x 3 Go to other windows (cycle through windows)) C-x o
Name Shortcuts Indent region fn1
C-M-\ or indent-region Indent region right Ctrl + right arrow Indent region left Ctrl + left arrow Indent region with keys Select region, C-x TAB, use arrows, ESC x 3
fn1
Indent region can be used to indent region to same column or
“delete” an indent by reset the first item in the region to the
desired indentation.
Name Shortcuts Mark / Select C-SPC (Spacebar) to start/stop highlight Mark - multiple select, region in rectangle, if in Evil, switch to Emacs C-x SPC or rectangle-mark-mode Mark - paragraph mark-paragraph Mark - select current paragraph M-h Cut (kill marked) text SHIFT-DEL or C-w Cut to end of current line C-k Copy (copy marked) text C-INSERT or M-w Paste (yank text back) SHIFT-INSERT or C-y Paste (using kill ring) M-y or M-Y (reverse direction) Undo - redo C-/ or C-_ Undo C-M-_ Undo Multiple Mode undo-tree-mode Kill word (delete word near cursor) M-d Comment Region / Uncomment region M-; / uncomment-region Clear kill ring (setq kill-ring nil)
For undo in region, select/mark region and undo will be limited to the
region, there are other operations like replace-string (search and
replace) that work the same way
See also:
Emacs Search with fzf, ripgrep, ivy, counsel, consult,
vertico - Emacs
Search with fzf, ripgrep, ivy, counsel, consult,
vertico
Default isearch, occur
Only matches characters, not regex unless using isearch-…-regex
Name Shortcuts Search in file isearch C-s or isearch-forward, C-s or isearch-backward Search in file isearch, cancel C-g Search in file isearch, enter at point Enter Search in file isearch, enter beginning of search word C-b Search in file isearch, repeat last search C-s C-s or C-r C-r Search in file isearch regex C-M-s or isearch-forward-regex, C-M-r or isearch-backward-regex Search with search results occur M-s-o or occur Search in file isearch with occur for buffer with results C-s <search-text> M-s-o (while in isearch) Search and highlight in file M-s h l or hi-lock-face-buffer Search and highlight in file, cancel M-s h u or hi-lock-unface-buffer aka unhighlight-regexp
Find/Search and Replace
Name Shortcuts Search and replace with extra functionality M-Shift-% or query replace or replace-string Find and replace search query M-% or query-replace Find and replace search query from isearch C-s <search-text> M-% (while in isearch, can also work with isearch regex commands) Find and replace search query, previous queries M-p
Other packages
Find and replace works for whole buffer or selected region
Name Shortcuts Search in file M-x swiper or helm-swoop Find and replace - Close all file buffers projectile-replace Find and replace - Close all file buffers dired-do-find-regexp-and-replace
(Q) in dired in a directory or with marked filesFind word -Search (backward) C-r or Backspace (aka DEL) Regexp “helper” M-x re-builder
Name Shortcuts Delete the character just before the cursor <DEL> Delete the next character after the cursor, delete line on character before empty lines C-d Kill the word immediately before the cursor M-<DEL> Kill the next word after the cursor M-d Kill from the cursor position to end of line C-k Kill to the end of the current sentence M-k
Use various functions to convert region/words to all uppercase,
lowercase or capitalize all words
Name Shortcuts Capitalize words in region Capitlize-dwim Upper case all words in region upcase-dwim Lower case all words in region downcase-dwim
Combine navigation commands with C-u
+ number plus the navigation
command to move by that number (e.g. C-u 2 C-f
to move forward 2
characters).
Name Shortcuts Move forward a character C-f Move backward a character C-b Move forward a word M-f= or `C-arrow-key-left Move backward a word M-b` or =C-arrow-key-right Move to next line C-n Move to previous line C-p Move to beginning of line C-a or home Move to end of line C-e or end Move to beginning of buffer M-< or =C-Home Move to end of buffer M-> or =C-End Move back to beginning of sentence M-a Move forward to end of sentence M-e Scroll up Page Up or C-v Scroll up other window M-Page Up Scroll down Page Down M-v Scroll down other window M-Page Down Increase font / text size C-x C-+ or text scale increase Navigate on headings / code parts in buffer counsel-imenu or imenu / M-g i (Emacs 29) Navigate on headings counsel-outline Switch to or restart ‘scratch ’ buffer scratch-buffer Center current line in buffer C-l Center current line in buffer, then top C-l C-l
Source: Issue 001 - System
Crafters - see
Tips of the Week
Name Shortcuts Draw line in buffer where fill-column is set display-fill-column-indicator-mode Automatically wrap paragraph text to fit within the specified width auto-fill-mode Center a region center-region Reshapes a paragraph of text so that it fits under 80 columns M-q or fill-paragraph
Set at where fill-column
cuts off for display fill column indicator
Source: GNU Emacs Manual -
Registers
Register is like a bookmark/saved text, position, window/frame
configuration, and rectangle for later use. Register names are a single
character like r.
Name Shortcuts Bookmark set C-x r m, bookmark-set Bookmark: jump to C-x r b , bookmark-jump Bookmark: list all C-x r l , list-bookmarks Bookmark: save all to file bookmark-save
Name Shortcuts Register: View contents of named register “r” view-register RET r Register: Record position of point in register “r” C-x r SPC r , point-to-register Register: Go to register “r”, recall frameset, number, etc. C-x r j r , jump-to-register Register: Copy region into register “r” C-x r s r , copy-to-register Register: Insert (paste) from register “r” C-x r i r, insert-register Register: Append region to register “r” append-to-register RET r Register: Prepend region to register “r” prepend-to-register RET r Register: Copy rectangle region to register “r” C-x r r r , copy-rectangle-to-register Register: Insert rectangle region to register “r” C-x r i r , copy-rectangle-to-register Register: Save window and frame configurations window-configuration-to-register Register: Save frames and windows configurations frameset-to-register Register: Restore window/frame config (same as jump) C-x r j r , jump-to-register Register: Store number in register “r” C-x r n r , number-to-register Register: Increment number in register “r” C-x r + r , increment-register Register: Save macro to register “r” C-x C-k x r , kmacro-to-register Register: Execute keyboard macro in register “r” C-x r j r
Save file and buffer names in registers:
(set-register r '(file . name))
Name Shortcuts Customize interface M-x customize Activate text major mode M-x text-mode Change margins for auto-fill-mode (auto line wrapping) C-x f Set directory local variables M-x add-dir-local-variable or use .dir-locals.el
Set directory local variables are useful for variables that only apply
in a certain directory like with using projectile-test-cmd, setting
file formatters and others
Name Shortcuts Record macro F3 Stop recording macro F4 Execute macro F4 Execute macro until end of file or error C-0 F4 Name, save macro M-x kmacro-name-last-macro= (use a prefix like mp-) Have Emacs generate Elisp for a macro M-x insert-kbd-macro
Tip: using insert-kbd=macro
, save for use as an interactive function
for repetitive use
Name Shortcuts Help C-h Help on feature C-h c Help on command C-h k Help on function (describe-function) C-h f= - can drill into function’s cod Help on variable (describe-variable) C-h v Help on key bindings for current function/minibuffer C-h b Help Apropos (search command keyword) C-h a Help Search - search all manuals info-apropos Read manuals (aka info) for installed packages C-h i Open emacs manual C-h r Help buffer - next / Previous page in Info buffer n / p
Name Shortcuts Suspend Emacs temporarily C-x C-z Run emacs for first time on command line emacs -q Check for unbalanced parentheses in Lisp check-parens=
Name Shortcuts Run elisp code eval-expression or M-: Evaluate the current elisp expression C-x C-e or eval-last-sexp Evaluate region or buffer C-c C-e or elisp-eval-region-or-buffer
Name Shortcuts Open shell M-x eshell Open other shell M-x term
Name Shortcuts Line mode to navigate buffer independent of prompt C-c C-j (on) / C-c C-k (off) Access Emacs command prompt C-x M-x= (my binding is F1) Scroll one screen at a time S-Page Up/Down Send C-c
SIGINT to terminal C-c C-c or C-g C-c C-c
to quit any keyboard commands and send SIGINT)
Run shell command asynchronously: M-&
- show command results in
separate buffer
Name Shortcuts Open web browser eww Open system browser on current file / url browse-url-of-file, browse-url Open html file, from eww or other browser eww-open-file Reader mode to remove nav headers and others R, eww-readable Copy text from eww with org mode links org-eww-copy-for-org-mode
Name Shortcuts At suggestions at cursor completion-at-point Flycheck, check LSP, linters, checkers enabled C-c ! v or flycheck-verify-setup Flycheck, LSP, linters, Errors List C-c ! l or flycheck-list-errors LSP Mode - Leader key C-c l LSP Mode - Find references C-c l g r LSP Mode - Find definitions C-c l g g LSP Mode - Refactor like rename C-c l r LSP Mode - Flymake tracks problems in file flymake-show-buffer-diagnostics LSP Mode - Code formatting C-c l = == or TAB LSP Mode - Display symbols with treemacs M-x lsp-treemacs-symbols LSP, Update LSP servers M-x lsp-update-servers LSP, Update LSP specific server M-x lsp-update-server Spelling - Flyspell autocorrect word C-M-i Spelling - Flyspell suggest words for correction C-c-$ Compile, run async shell command, output buffer M-x compile Compile, go to next error and file C-x ` Compile, run last compile command again M-x recompile
Source: ediff Basics -
Prot
Function to see difference between files side by side
When going through diffs, see ediff control panel for description of
differences
Buffers are normal buffers and can be edited
ediff can be used in magit status, when selecting commits
Name Shortcuts Diff on Files ediff-files Diff on 3 Files ediff3-files Diff on buffers ediff-buffers Diff on buffers, ediff help ? Diff, ediff move difference at point in file A to B a Diff, ediff move difference at point in file B to A b Diff, ediff next, previous difference n, N Diff, ediff diff output difference D Diff, ediff quit q
Name Shortcuts Recover file from autosave M-x recover-file
Name Shortcuts List all fonts M-x list-faces-display
Name Shortcuts Convert strokes to commands, see more with strokes-help
Supports remote systems and docker, podman, and kubernetes connection
methods
Name Shortcuts Play game, pong M-x pong Play game, snake M-x snake Play game, tetris M-x tetris Psychotherapy with Eliza M-x doctor