Basic Emacs


Although emacs has sophisticated features, the basics are easy to learn. Ordinary characters that are typed are put directly into the text. Commands to emacs are given by control characters (denoted C-) and Meta characters (denoted M-). For example, C-f would be entered by holding down the Ctrl key while typing f. On keyboards, Meta is Alt, Option on a Mac, or Esc. Cursor positioning can be done with arrow keys or the left mouse button. Documentation and options can be found in menus at top of screen.

C-f, C-b Move the cursor Forward/Backward one character.
C-p, C-n Move to the Previous/Next line.
C-a Move cursor to beginning of line.
C-e Move cursor to End of line.
M-f Move the cursor Forward one word.
M-b Move the cursor Backward one word.
C-v Move forward down the text by a screenful.
M-v Move backwards up the text by a screenful.
C-l Center the display around the cursor position.
M-< Go to the beginning of the file.
M-> Go to the end of the file.
C-d Delete a character.
M-d Delete a word (saved: see C-y).
C-k Kill to end of line. Two individual C-k's delete a line
and its carriage return. (saved: see C-y.)
C-y Yank back (Paste) what was killed earlier. Material can be duplicated
by yanking it back multiple times. A line can be re-executed
by placing the cursor at the end of the line and entering carriage return.
C-u n Repeat the next command n times. For example, C-u 6 C-k C-y C-y
will kill six lines (including the carriage returns) and make two copies.
C-s str Search for the string str. When found, enter ESCape to get
out of search mode. If you want the next or previous
occurrence of str, just enter C-s or C-r again.
C-r str Reverse search for str .
C-x C-v Visit a new file; EMACS will prompt for the file name.
C-x C-w Write out the text buffer to a file.
C-x C-s Save the text buffer in the file it came from.
C-g Abort the current command.
M-x lisp mode Enter Lisp mode, useful for indentation.
M-x run lisp Run Lisp/Clojure within Emacs.
C-x 5 Split the screen in half vertically to make two windows.
C-x 2 Split the screen in half horizontally to make two windows.
C-M-z Evaluate the form under the cursor from Lisp.
C-x C-c Stop Emacs.