You are on page 1of 2

U N I V E R S I T Y IN F O R M A T I O N T E C H O L O G Y S E R V I C E S

Tags Registers Simple Customization


find a tag (a definition) M-. save region in register C-x r s The intended audience here is the person who wants to make
find next occurrence of tag C-u M-. insert register contents into buffer C-x r i simple customizations and knows Lisp syntax.
specify a new tags file M-x visit-tags-table save value of point in register C-x r SPC Here are some examples of binding global keys in Emacs
regexp search on all files in tags table jump to point saved in register C-x r j Lisp. Note that you cannot say “\M-\# ”; you must say
M-x tags-search “\e\# ”.
run query-replace on all the files
M-x tags-query-replace Info
(global-set-key "\C-cg" 'goto-line)
(global-set-key "\C-x\C-k" 'kill-region) Emacs reference card
continue last tags search or query-replace M-, enter the Info documentation reader C-h i (global-set-key "\e\#" 'query-replace-
Moving within a node: regexp)
scroll forward SPC This reference card lists some of the most
Rectangles scroll reverse DEL An example of setting a variable in Emacs Lisp:
common commands for the Emacs text
copy rectangle to register C-x r r beginning of node . (dot) (setq backup-by-copying-when-linked t)
kill rectangle C-x r k Moving between nodes: editor under Unix. Emacs is available on
yank rectangle C-x r y next node n most UITS Unix systems.
open rectangle, shifting text right C-x r o previous node p Writing Commands
blank out rectangle C-x r c move up u (defun command-name ( args)
prefix each line with a string C-x r t select menu item by name m “documentation”
select nth menu item by number (1–5) n (interactive “template”)
follow cross reference (return with l) f body)
Abbrevs return to last node you saw 1
add global abbrev C-x a g return to directory node d An example:
add mode-local abbrev C-x a l go to any node by name g (defun this-line-to-top-of-window (line)
add global expansion for this abbrev C-x a i g Other: “Reposition line point is on to top of
add mode-local expansion for this abbrev C-x a i l run Info tutorial h window. With ARG, put point on line ARG.
explicitly expand abbrev C-x a e list Info commands ? Negative counts from bottom.”
expand previous word dynamically M-/ quit Info q (interactive “P”)
search nodes for regexp s (recenter (if (null line)
0
Regular Expressions (prefix-numeric-value line)))) Gnu
any single character except a newline . (dot)
Keyboard Macros Emacs
start defining a keyboard macro C-x ( The argument to interactive is a string specifying how to get
zero or more repeats * the arguments when the function is called interactively. Type
one or more repeats + end keyboard macro definition C-x )
execute last-defined keyboard macro C-x e C-h f interactive for more information.
zero or one repeat ?
any character in the set [...] append to last keyboard macro C-u C-x (
any character not in the set [^...] name last keyboard macro
beginning of line ^ M-x name-last-kbd-macro
end of line $ insert Lisp definition in buffer Copyright (c) 1987, 1993 Free Software Foundation, Inc.
quote a special character c \c M-x insert-kbd-macro Permission is granted to make and distribute copies of this
alternative (“or”) \| card provided the copyright notice and this permission
grouping \(...\) notice are preserved on all copies.
nth group \n Commands Dealing with Emacs Lisp For copies of the GNU Emacs manual, write to the Free
beginning of buffer \‘ eval sexp before point C-x C-e Software Foundation, Inc., 675 Massachusetts Ave,
end of buffer \’ eval region M-x eval-region Cambridge MA 02139.
word break \b eval entire buffer M-x eval-current-buffer
University Communications and Planning has made slight
January 1998
not beginning or end of word \B read and eval minibuffer M-ESC
modifications to this reference card. Please send comments
beginning of word \< read and eval Emacs Lisp file M-x load-file
about this publication to: pubster@indiana.edu.
end of word \> load from standard system directory
any word-syntax character \w M-x load-library
any non-word-syntax character \W For the most current version of this document
character with syntax c \sc on the World Wide Web, set your browser to:
character with syntax not c \Sc http://www.indiana.edu/~ucspubs/b131/

I N D I A N A U N I V E R S I T Y
C – Press and hold down the CONTROL key while pressing the next letter. M – Press and release the ESC key (or press and hold the Meta key, if your keyboard has one).
Starting Emacs Incremental Search Query Replace Case Change
To enter GNU Emacs 19, just type its name: emacs search forward (can be repeated) C-s interactively replace a text string M-% uppercase word M-u
To read in a file to edit, see Files, below. search backward (can be repeated) C-r using regular expressions lowercase word M-l
regular expression search M-C-s M-x query-replace-regexp capitalize word M-c
reverse regular expression search M-C-r uppercase region C-x C-u
Leaving Emacs Valid responses in query-replace mode are: lowercase region C-x C-l
suspend Emacs (or iconify it under X) C-z These commands are available during searching: replace this one, go on to next SPC or y capitalize region M-x capitalize-region
exit this Emacs session C-x C-c select previous search string M-p replace this one, don’t move ,
select next later search string M-n skip to next without replacing DEL or n
undo effect of last character DEL replace all remaining matches ! The Minibuffer
General exit incremental search
abort current search
RET
C-g
back up to the previous match
exit query-replace
^
ESC or RET
The following keys are defined in the minibuffer:
press and hold the CTRL key C- complete as much as possible TAB
enter recursive edit (M-C-c to exit) C-r complete up to one word SPC
press and release ESC (or press and hold META) M-
give an argument to command C-u command complete and execute RET
give a numerical argument # to command
Motion show possible completions ?
C-u # command entity to move over backward forward Multiple Windows fetch previous minibuffer input M-p
character C-b C-f delete all other windows C-x 1 fetch next later minibuffer input M-n
word M-b M-f delete this window C-x 0 regexp search backward through history M-r
Files line
go to line beginning (or end)
C-p
C-a
C-n
C-e
split window in two vertically
split window in two horizontally
C-x 2
C-x 3
regexp search forward through history
abort command
M-s
C-g
read a file into Emacs C-x C-f
sentence M-a M-e scroll other window M-C-v
save a file back to disk C-x C-s
paragraph M-{ M-} switch cursor to another window C-x o Type C-x ESC ESC to edit and repeat the last command
save all files C-x s
page C-x [ C-x ] shrink window shorter M-x shrink-window that used the minibuffer. The following keys are then
insert contents of another file into this buffer C-x i
sexp M-C-b M-C-f grow window taller C-x ^ defined:
replace this file with the file you really want C-x C-v
function M-C-a M-C-e shrink window narrower C-x { previous minibuffer command M-p
write buffer to a specified file C-x C-w
go to buffer beginning (or end) M-< M-> grow window wider C-x } next minibuffer command M-n
scroll to next screen/prev screen M-v C-v select buffer in other window C-x 4 b
scroll right/left C-x > C-x < display buffer in other window C-x 4 C-o
Getting Help scroll current line to center of screen C-l find file in other window C-x 4 f Buffers
begin tutorial for first-time users C-h t find file read-only in other window C-x 4 r select another buffer C-x b
enter Help system C-h run Dired in other window C-x 4 d list all buffers C-x C-b
remove Help window C-x 1 Killing and Deleting find tag in other window C-x 4 . kill a buffer C-x k
scroll Help window ESC C-v
entity to kill backward forward
apropos: show commands matching a string C-h a
character (delete, not kill) DEL C-d
show the function a key runs C-h c
word M-DEL M-d Formatting Transposing
describe a function C-h f
line (to end of) M-0 C-k C-k indent current line (mode-dependent) TAB transpose characters C-t
get mode-specific information C-h m
sentence C-x DEL M-k indent region (mode-dependent) M-C-\ transpose words M-t
sexp M--M-C-k M-C-k indent sexp (mode-dependent) M-C-q transpose lines C-x C-t
kill region C-w indent region rigidly arg columns C-x TAB
Error Recovery copy region to kill ring M-w insert newline after point C-o
transpose sexps M-C-t
abort partially typed or executing command C-g kill through next occurrence of char M-z char move rest of line vertically down M-C-o
recover a file lost by a system crash
M-x recover-file
yank back last thing killed
replace last yank with previous kill
C-y
M-y
delete blank lines around point
join line with previous (with arg, next)
C-x C-o
M-^
Spelling Check
undo an unwanted change C-x u or C-_ check spelling of current word M-$
delete all white space around point M-\
restore a buffer to its original contents check spelling of all words in region
put exactly one space at point M-SPC
M-x ispell-region
M-x revert-buffer Marking fill paragraph M-q
check spelling of entire buffer M-x ispell-buffer
redraw garbaged screen C-l set fill column C-x f
set mark here C-SPC or C-2 or C-@
exchange point and mark C-x C-x set prefix each line starts with C-x .
set mark arg words away
mark paragraph
M-@
M-h
Shells
mark page C-x C-p execute a shell command M-!
mark sexp M-C-SPC or M-C-@ run a shell command on the region M-|
mark function M-C-h filter region through a shell command C-u M-|
mark entire buffer C-x h start a shell in window *shell* M-x shell

C – Press and hold down the CONTROL key while pressing the next letter. M – Press and release the ESC key (or press and hold the Meta key, if your keyboard has one).