Emacs Commands Cheat Sheet

Starting and Leaving Emacs

  • To enter GNU Emacs
  • $ emacs

  • To suspend Emacs (or iconify it under X)
  • Ctrl-z

  • To exit Emacs permanently
  • Ctrl-x Ctrl-c

    Files, Buffers and Windows

  • To open a file, existing or new
  • Ctrl-x Ctrl-f

  • To save file/buffer content
  • Ctrl-x Ctrl-s

  • To save buffer as a different file (Save As)
  • Ctrl-x Ctrl-w

  • To save all open files/buffers
  • Ctrl-x s

  • To insert contents of another file into this buffer
  • Ctrl-x i

  • To kill current buffer and open another file
  • Ctrl-x Ctrl-v

  • To kill (close) a buffer
  • Ctrl-x k

  • To toggle read-only status of buffer
  • Ctrl-x Ctrl-q

  • To select another buffer
  • Ctrl-x b

  • To list all buffers
  • Ctrl-x Ctrl-b

  • To split Window
  • Ctrl-x 2 or Ctrl-x 3

  • To unsplit windows (maximize selected window, within its Frame)
  • Ctrl-x 1

  • To select next window
  • Ctrl-x o

    Cursor Motion

  • To move the TextCursor forward a character
  • Ctrl-f

  • To move the TextCursor backward a character
  • Ctrl-b

  • To move the TextCursor forward a line
  • Ctrl-n

  • To move the TextCursor backward a line
  • Ctrl-p

  • Go to the beginning of the line
  • Ctrl-a

  • Go to the end of the line
  • Ctrl-e

  • To move the TextCursor forward a word
  • Alt-f

  • To move the TextCursor backward a word
  • Alt-b

  • To move the TextCursor forward a sentence
  • Alt-e

  • To move the TextCursor backward a sentence
  • Alt-a

  • Go to the beginning of the buffer
  • Alt-<

  • Go to the end of the buffer
  • Alt->

  • To move the TextCursor forward a paragraph
  • Alt-{

  • To move the TextCursor backward a paragraph
  • Ctrl-x [

  • To move the TextCursor backward a page
  • Ctrl-x ]

  • To move the TextCursor backward a sentence
  • Alt-a

  • To scroll to next screen
  • Ctrl-v

  • To scroll to previous screen
  • Alt-v

  • To scroll left
  • Ctrl-x <

  • To scroll right
  • Ctrl-x >

  • To scroll current line to center, top, bottom
  • Ctrl-l

  • To goto line
  • Alt-g g

  • Back to indentation
  • Alt-m

    Killing and Deleting

  • To delete a character backward
  • DEL

  • To delete a character forward
  • Ctrl-d

  • To delete a word backward
  • Alt-DEL

  • To delete a word forward
  • Alt-d

  • To delete a line backward
  • Alt-O Ctrl-k

  • To delete a line forward
  • Ctrl-k

  • To delete a sentence backward
  • Ctrl-x DEL

  • To delete a sentence forward
  • Alt-k

    Incremental Search

  • To search forward
  • Ctrl-s

  • To search backward
  • Ctrl-r

  • To perform regular expression search
  • Ctrl-Alt-s

  • To perform reverse regular expression search
  • Ctrl-Alt-r

  • To select previous search string
  • Alt-p

  • To select next later search string
  • Alt-n

  • To exit incremental search
  • RET

  • To undo effect of last character
  • DEL

  • To abort current search
  • Ctrl-g

    Query Replace

  • To interactively replace a text string
  • Alt-%

  • To replace a text string using regular expressions
  • Alt-x query-replace-regexp
    When query-replace is in progress:
    q’ or ‘RET’ to quit (no more replacements)
    `.’ to replace the current match and quit
    SPC’ to replace the current match and find the next one
    `!’ to replace all remaining matches and then quit
    E’ to change (edit) the replacement string
    Ctrl-l’ to refresh the screen
    Y’ to replace all across all buffers of a multi-buffer query-replace
    N’ to skip to the next buffer of a multi-buffer query-replace
    `?’ to see this help list of possibilities

    Formatting and Case Change

  • To indent current line (mode-dependent)
  • TAB

  • To indent region (mode-dependent)
  • Ctrl-Alt-\

  • To indent indent region rigidly arg columns
  • Ctrl-x TAB

  • To indent for comment
  • Alt-;

  • To insert newline after point
  • Ctrl-o

  • To move rest of line vertically down
  • Ctrl-Alt-o

  • To delete blank lines around point
  • Ctrl-x Ctrl-o

  • To delete all white space around point
  • Alt-\

  • To put exactly one space at point
  • Alt-SPC

  • To fill paragraph
  • Alt-q

  • To make a word uppercase
  • Alt-u

  • To make a word lowercase
  • Alt-l

  • To capitalize a word
  • Alt-c

  • To make uppercase region
  • Ctrl-x Ctrl-u

  • To make lowercase region
  • Ctrl-x Ctrl-l

    Marking

  • To set mark at current position
  • Ctrl-@ or Ctrl-SPC

  • To exchange point and mark
  • Ctrl-x Ctrl-x or Ctrl-SPC

  • To set mark arg words away
  • Alt-@ or Ctrl-SPC

  • To mark paragraph
  • Alt-h or Ctrl-SPC

  • To mark page
  • Ctrl-x Ctrl-p or Ctrl-SPC

  • To mark function
  • Ctrl-Alt-h or Ctrl-SPC

  • To mark entire buffer
  • Ctrl-x h or Ctrl-SPC

    Spelling Check

  • To check spelling of current word
  • Alt-$

  • To check spelling of all words in region
  • Alt-x ispell-region

  • To check spelling of entire buffer
  • Alt-x ispell-buffer

    Other Simple Editing

  • To Transpose (swap) adjacent characters
  • Ctrl-t

  • To Transpose adjacent words
  • Alt-t

  • To Transpose lines
  • Ctrl-x Ctrl-t

  • To Move line 2 lines forward
  • Ctrl-u Ctrl-x Ctrl-t

  • To Join previous line
  • Alt-^

  • To Join next line
  • Ctrl-1 Alt-^
    Bash CheatSheet Home Vi CheatSheet