GNU Emacs Reference Card (reduced)

Starting Emacs

To enter GNU Emacs, just type its name: emacs

Leaving Emacs

exit Emacs permanently                             C-x C-c


read a file into Emacs                             C-x C-f
save a file back to disk                           C-x C-s
save all files                                     C-x s
write buffer to a specified file                   C-x C-w
    (this is basically "save as")

Getting Help

The Help system is simple. Type C-h and follow the directions. If you are a first-time user, type C-h t for a tutorial.
remove Help window                                 C-x 1
scroll Help window                                 ESC C-v

apropos: show commands matching a string           C-h a
show the function a key runs                       C-h c
describe a function                                C-h f
get mode-specific information                      C-h m

Error Recovery

abort partially typed or executing command         C-g
undo an unwanted change                            C-x u or C-_

Incremental Search

search forward                                     C-s
search backward                                    C-r
regular expression search                          C-M-s
reverse regular expression search                  C-M-r

exit incremental search                            RET
abort current search                               C-g
Use C-s or C-r again to repeat the search in either direction. If Emacs is still searching, C-g cancels only the part not done.


entity to move over                        backward      forward

character                                  C-b           C-f
word                                       M-b           M-f
line                                       C-p           C-n
go to line beginning (or end)              C-a           C-e
sentence                                   M-a           M-e
go to buffer beginning (or end)            M-<           M->

scroll current line to center of screen            C-u C-l

Killing and Deleting

entity to kill                             backward      forward

character (delete, not kill)               BACKSPC       C-d or DELETE
word                                       M-BACKSPC     M-d or M-DELete
line (to end of)                           M-0 C-k       C-k
sentence                                   M-BACKSPC     M-k

kill region                                        C-w
copy region to kill ring                           M-w
yank back last thing killed                        C-y


set mark here                                      C-SPC

Query Replace

interactively replace a text string                M-%
using regular expressions             		   M-x query-replace-regexp
Valid responses in query-replace mode are:
replace this one, go on to next                    SPC
replace this one, don't move                       ,
skip to next without replacing                     DEL
replace all remaining matches                      !
back up to the previous match                      ^
exit query-replace                                 ESC


indent current line (mode-dependent)               TAB
indent region (mode-dependent)                     M-x-indent-region
fill paragraph                                     M-q


select another buffer                              C-x b
list all buffers                                   C-x C-b
kill a buffer                                      C-x k

Spelling Check

check spelling of current word                     M-$
check spelling of all words in region              M-x ispell-region
check spelling of entire buffer                    M-x ispell-buffer


execute a shell command                            M-!
run a shell command on the region                  M-_
filter region through a shell command              C-u M-_
start a shell in window *shell*                    M-x shell


enter the Info documentation reader                C-h i
Moving within a node:
   scroll forward                                  SPC
   scroll reverse                                  DEL
   beginning of node                               .   (dot)
Moving between nodes:
   next node                                       n
   previous node                                   p
   move up                                         u
   select menu item by name                        m
   select nth menu item by number (1-5)            n
   follow cross reference (return with l)          f
   return to last node you saw                     l
   return to directory node                        d
   go to any node by name                          g
   run Info tutorial                               h
   list Info commands                              ?
   quit Info                                       q
   search nodes for regexp                         s

Simple Customization

Here are some examples of binding global keys in Emacs Lisp. Note that you cannot say ""M-#"; you must say ""e#".
(global-set-key ""C-cg" 'goto-line)
(global-set-key ""C-x"C-k" 'kill-region)
(global-set-key ""e#" 'query-replace-regexp)

Configuration options you want to be effective every time you start emacs should be placed in you .emacs file in your home directory. For example, to turn on some nice paren matching stuff place the following line into your .emacs:

(show-paren-mode t)

note: ';' acts as a comment in .emacs . An example of setting a variable in Emacs Lisp:
(setq backup-by-copying-when-linked t)
           Copyright c 1993 Free Software Foundation, Inc.
              designed by Stephen Gildea, May 1993 v2.0
              for GNU Emacs version 19 on Unix systems
Permission is granted to make and distribute copies of this card provided the copyright notice and this permission notice are preserved on all copies.