Skip to content

Instantly share code, notes, and snippets.

@kiasaki
Last active December 19, 2017 09:15
Show Gist options
  • Save kiasaki/95bef31961871522c11c to your computer and use it in GitHub Desktop.
Save kiasaki/95bef31961871522c11c to your computer and use it in GitHub Desktop.
emacs_cheatsheet

Learning of emacs in progres...

  • M-x eval-buffer : Self-explanatory

  • M-x replace-string : Self-explanatory

  • C-x C-c : Quit emacs

  • C-g : Cancel current command (keyboard-quit)

Buffers

  • C-x C-s : Save buffer
  • C-x C-w : Save as
  • C-x k RET : Kill current buffer
  • C-x b : Switch buffers
  • C-x C-b : buffer managment (ibuffer)
    • q : Quit
    • , : Rotate between sorting modes
    • s a : Sort alphabeticly
    • / m : Filter buffers by major
    • / n : Filter buffers by name
    • / c : Filter buffers by contents
    • / f : Filter buffers by filename
    • / g RET <group name> : Give a group name to current filter
    • / / : Clear filters
    • C-o : open in adjacent/new window
    • o : Open buffer in current window
    • g : Refresh
    • m : Mark (select) a buffer
      • A : View/Open marked buffers
      • S : Save buffer changes
      • D : Close buffers
      • V : Revert/undo changes
      • u : Un-select/mark a buffer

Windows

  • C-x o : switch window
  • C-x 0 : Close current window
  • C-x 1 : Close all but current window
  • C-x 3 : Make a new window split under (with same buffer)
  • C-x 3 : Make a new window split to the right (with same buffer)

Moving point

  • C-p : previous-line
  • C-n : next-line
  • C-a : move-beginning-of-line
  • C-e : move-end-of-line
  • M-f : forward-word
  • M-b : backward-word
  • CM-f : forward-sexp (logical expression (){}[]''"")
  • CM-b : backward-sexp
  • M-< : beginning-of-buffer
  • M-> : end-of-buffer
  • C-v : scroll-up-command
  • M-v : scroll-down-command
  • M-g M-g : goto-line (take n number prefix)
  • M-g TAB : move-to-column (take n number prefix)

Editing

  • C-k : Kill to end of line
  • C-d : Kill char at point
  • C-w : Kill selected region
  • M-d : Kill forward to end of word
  • M-DEL : Kill backward to beginning of word
  • C-y : yank Insert last item in the killring (paste)
  • M-y : yank-pop
  • C-x u : Undo (or C-\)

Helpers

  • M-; : Comment out selected region (or add comment at eol)
  • M-/ : Autocomplete
  • M-! : Run command in shell
  • C-s : Simple search

Markers/Regions

  • C-SPC : Place a marker (then move it'll make a region or C-SPC again to deactivate)
  • C-u C-SPC : Teleport point back to last mark
  • C-x C-x : exchange-point-and-mark
  • C-w : Kill a region (or current line)
  • M-w : Copy a region (or current line)
  • C-y : Paste a last item in killring

Macros

  • C-x ( : Start recording
  • C-x ) : End recording
  • C-x e : Execute recorded macro

Plugin: Helm & Projectile

  • C-c p h : helm-projectile
  • C-c p f : helm-projectile-find-file
  • C-c p b : helm-projectile-switch-to-buffer
  • C-c p ! : run a shell-command in project root
  • C-c p & : run an async-shell-command in project root
  • C-c s s : Switch project (also s-s)
  • s-t : helm-projectile

Plugin: Perspective

  • C-x x s : persp-switch
  • C-x x c : persp-kill
  • C-x x r : persp-rename
  • C-x x n|<right> : persp-next
  • C-x x p|<left> : persp-prev
@Snger
Copy link

Snger commented Dec 19, 2017

-- C-x 3 : Make a new window split under (with same buffer)
+- C-x 2 : Make a new window split under (with same buffer)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment