Skip to content

Instantly share code, notes, and snippets.

@AyakoGFX
Created February 10, 2025 18:22
Show Gist options
  • Select an option

  • Save AyakoGFX/5ca7239dcf41e04811f2fc210606c9a5 to your computer and use it in GitHub Desktop.

Select an option

Save AyakoGFX/5ca7239dcf41e04811f2fc210606c9a5 to your computer and use it in GitHub Desktop.
Emacs Cheat Sheet for Beginners

Understanding Keybindings in Emacs

  • Emacs uses special keys for shortcuts, often written in a notation like C-x C-f or M-f.

Control (C-) Key

  • C- stands for **Control**.
  • C-x means **press and hold Control (Ctrl) and then press =x=**.
  • Example: C-x C-f means:
    1. Hold Ctrl
    2. Press x
    3. Then press f while still holding Ctrl

Meta (M-) Key

  • M- stands for **Meta**, which was an old key on Lisp machines.
  • Today, Meta is usually the =Alt= key (on most keyboards).
  • Example: M-f means:
    1. Hold Alt
    2. Press f

Example Commands

  • C-s → Start a search
  • M-f → Move forward one word

Opening and Closing Emacs

  • emacs → Start Emacs
  • C-x C-c → Exit Emacs

Files

  • C-x C-f → Open or create a file
  • C-x C-s → Save the current file

Navigation

  • C-f → Move forward one character
  • C-b → Move backward one character
  • C-n → Move to the next line
  • C-p → Move to the previous line
  • M-f → Move forward one word
  • M-b → Move backward one word
  • C-a → Move to the beginning of the line
  • C-e → Move to the end of the line
  • M-< → Move to the beginning of the file
  • M-> → Move to the end of the file

Editing

  • C-d → Delete forward
  • M-d → Delete forward word
  • C-k → Kill (cut) to end of line
  • M-w → copy
  • C-y → Yank (paste)
  • M-y → Cycle through previous yanks
  • C-/ or C-x u → Undo

Undo

to undo press C-/

Redo

  • to Redo, simply do something unrelated like such as C-e or C-n what ever as long its not C-/ and press C-/ to redo
    • Simply the undo and redo is the same key if you want to undo press C-/ to redo do somthing like C-e or C-n and press C-/

Buffers (Open Files)

  • C-x b → Switch buffer
  • C-x C-b → List buffers
  • C-x k → Kill (close) buffer

Windows (Split View)

  • C-x 0 → Close current window
  • C-x o → Switch to another window
  • C-x 2 → Split window horizontally
  • C-x 3 → Split window vertically
  • C-x 1 → Close other windows

Search

  • C-s → Forward search
  • C-r → Reverse search

Help

  • C-h t → Open tutorial
  • C-h k → Describe a keybinding
  • C-h f → Describe a function
  • C-h v → Describe a variable

Opening and Closing Emacs

  • emacs → Start Emacs
  • C-x C-c → Exit Emacs
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)

(global-display-line-numbers-mode 1)

(setq custom-file (locate-user-emacs-file "custom.el"))
(load custom-file t)

(add-to-list 'default-frame-alist '(font . "fontname-size")) ;;ex Monospace-20 or JetBrainsMono Nerd Font-20
(setq inhibit-splash-screen t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment