GNU EMACS 19 Quick Reference Card Last updated: Mon Apr 5 14:47:25 1999 C-A means Control-A, etc. (also called ^A) M-A means Meta-A, etc. (also called Escape-A) C-M-A means Control-Meta-A (also called C-M-A) These mean hold down the 2 or 3 keys simultaneously. On Sun and Dec workstations, the Meta key is usually the one to the left of the space bar. On ASCII terminals, M-A may be replaced by the 2-character sequence ESC-A. For commands involving the C- or M- prefix, case is insignificant, so C-A = C-a and C-M-A = C-M-a. Otherwise, case is significant. This card is for Emacs Version 19, the version available on most CCS Unix machines as /arch/gnu/bin/emacs . Emacs has proceeded to version 20, but most of the keystrokes are the same. Emacs 19 features multiple windows (called "frames") and a modern WIMP (WIndow-Menu-Pointer) interface. A tutorial is available from the Help menu. Many useful commands are also found on the menu bar. **************************************************************** Initialization: Emacs is a customizable text editor with a powerful window facility. In order to run emacs effectively on our system, you need to put a file called .emacs in your home directory. See the section "Customization" below on how to do this for now. A minimal .emacs, with useful defaults, can be found at /course/com3351/pub/.emacs . **************************************************************** Getting started/getting out: to start: emacs filename emacs -nw Run emacs in terminal window (useful under telnet, etc.) to exit: C-x C-c (it will ask which modified files should be saved, so this can be used for both normal and abnormal exits) Also [Files|Exit Emacs] illegal-operation C-g (to abort a command) undo C-x u (to undo a command) redisplay C-l (to redisplay the screen) **************************************************************** The Region: The region is the space between the dot (just to left of cursor) and the mark. You can set the mark using C-@, C-spc, or the mouse (see below). Using (transient-mark-mode) makes the region visible, and allows operations on the region only when it is visible. Useful commands: set-mark-command M-1, C-@ exchange-dot-and-mark C-x C-x delete-region-to-kill-buffer C-w copy-region-as-kill M-w Like C-w but doesn't delete yank-from-killbuffer C-y The standard way to move or copy blocks of text is to use C-w and C-y. You can C-y the same text several times. **************************************************************** The Mouse: Under the X window system, mouse motion is supported. The commands on the mouse buttons are: left point to mouse pos; drag to create region. shift-left open font selection window C-left open buffer selection menu middle yank at click [C-y] right region to emacs kill-buffer [M-w] and also to X selection buffer double-right same, but also deletes the region [C-w] **************************************************************** Cursor Motions: Move Delete Undo L R L R Character C-b C-f DEL C-d Word M-b M-f M-DEL M-d Lines C-p C-n Beg/End of Line C-a C-e C-k C-y Sentence M-a M-e Next/Prev Window C-x o C-x o C-x 0 Page M-v C-v Paragraph M-[ M-] Beg/End of File M-< M-> S-expression C-M-b C-M-f Region C-x C-x C-x C-x C-w C-y Also, the arrow keys are supported on almost all keyboards. **************************************************************** Frames: A frame is an area on the screen, corresponding to what is usually called a window. find-file-other-frame C-x 5 f (open file in a new frame; the other standard way of switching files) switch-to-buffer-other-frame C-x 5 b delete-frame C-x 5 0 (deletes current frame) **************************************************************** Buffers: A buffer is a chunk of text. It may or may not be associated with a file. A buffer is displayed by associating it with a window (an area on the screen). find-file C-x C-f (the standard way of switching files) list-buffers C-x C-b switch-to-buffer C-x b save-some-buffers C-x s (saves modified buffers; asks about each) **************************************************************** Windows: A window is an area in a frame, usually associated with a buffer. delete-window C-x 0 (deletes current window) delete-other-windows C-x 1 other-window C-x o split-windows-vertically C-x 2 (splits screen into 2 windows) **************************************************************** Getting help: GNU Emacs has a powerful help command. Help commands are always accessed by C-h. The learn-by-doing tutorial (C-h t) is highly recommended. Most help commands are available from the help menu. Some of the options are: help-with-tutorial C-h t (select the learn-by-doing tutorial) apropos C-h a (prints list of relevant commands --very useful) describe-command C-h d describe-key C-h k describe-bindings C-h b (makes list of current key bindings) describe-mode C-h m (describes features of current major mode) help-with-help C-h C-h (describes options for help command) **************************************************************** Searches: isearch-forward C-s (these are incremental searches) isearch-reverse C-r query-replace-string M-% (use C-h for help here, too) **************************************************************** Miscellaneous: redisplay screen C-l newline-and-indent LF (useful for pgms) quote-character C-q (Useful for putting ctl chars in files) filter-region M-| (run region thru unix filter pgm) shell M-s (starts inferior shell in a window) capitalize word M-c (works on FOLLOWING word!) upper-case word M-u (works on FOLLOWING word!) lower-case word M-l (ditto) fill-paragraph M-q (works on whole definitions in programs) dabbrev-expand M-/ (copy recent similar word; useful for pgms!) **************************************************************** Extended Commands: There are too many commands in emacs for any reasonable set of keys. Hence any command can be executed by typing M-x followed by its name. **************************************************************** Scheme Mode: M-x run-scheme start inferior scheme process in a window indent-line TAB indent current line correctly newline-and-indent LF, C-j newline and indent it scheme-send-defun-and-go C-M-x send current definition to scheme process Files with extensions .scm will automatically be put in scheme mode. **************************************************************** Mail/News: Emacs supports several mail readers (rmail, VM, mh-e) and several news readers (most notably gnus). **************************************************************** Customization: Emacs is highly customizable, using a Lisp-like extension language. Indeed, most of emacs itself is written in Emacs-Lisp. When your account is created, it includes a default .emacs file that provides See the clue sheet on Emacs or read your .emacs for more information.