Emacs

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

GNU Emacs 21 Reference Card Motion Multiple Windows

When two commands are shown, the second is for “other frame.”
entity to move over backward forward
Starting Emacs character C-b C-f delete all other windows C-x 1
word M-b M-f split window, above and below C-x 2 C-x 5 2
To enter GNU Emacs 21, just type its name: emacs line C-p C-n delete this window C-x 0 C-x 5 0
To read in a file to edit, see Files, below. go to line beginning (or end) C-a C-e split window, side by side C-x 3
sentence M-a M-e
scroll other window C-M-v
paragraph M-{ M-}
Leaving Emacs page C-x [ C-x ] switch cursor to another window C-x o C-x 5 o
sexp C-M-b C-M-f select buffer in other window C-x 4 b C-x 5 b
suspend Emacs (or iconify it under X) C-z display buffer in other window C-x 4 C-o C-x 5 C-o
function C-M-a C-M-e
exit Emacs permanently C-x C-c find file in other window C-x 4 f C-x 5 f
go to buffer beginning (or end) M-< M->
find file read-only in other window C-x 4 r C-x 5 r
scroll to next screen C-v run Dired in other window C-x 4 d C-x 5 d
Files scroll to previous screen M-v find tag in other window C-x 4 . C-x 5 .
scroll left C-x <
read a file into Emacs C-x C-f grow window taller C-x ^
scroll right C-x >
save a file back to disk C-x C-s shrink window narrower C-x {
scroll current line to center of screen C-u C-l
save all files C-x s grow window wider C-x }
insert contents of another file into this buffer C-x i
replace this file with the file you really want C-x C-v Killing and Deleting Formatting
write buffer to a specified file C-x C-w indent current line (mode-dependent) TAB
version control checkin/checkout C-x C-q entity to kill backward forward
character (delete, not kill) DEL C-d indent region (mode-dependent) C-M-\
word M-DEL M-d indent sexp (mode-dependent) C-M-q
Getting Help line (to end of) M-0 C-k C-k indent region rigidly arg columns C-x TAB
sentence C-x DEL M-k insert newline after point C-o
The help system is simple. Type C-h (or F1) and follow the di- sexp M-- C-M-k C-M-k move rest of line vertically down C-M-o
rections. If you are a first-time user, type C-h t for a tutorial. delete blank lines around point C-x C-o
kill region C-w
remove help window C-x 1 join line with previous (with arg, next) M-^
copy region to kill ring M-w
scroll help window C-M-v delete all white space around point M-\
kill through next occurrence of char M-z char
apropos: show commands matching a string C-h a put exactly one space at point M-SPC
yank back last thing killed C-y fill paragraph M-q
show the function a key runs C-h c
replace last yank with previous kill M-y set fill column C-x f
describe a function C-h f
get mode-specific information C-h m set prefix each line starts with C-x .
Marking set face M-g
Error Recovery Case Change
set mark here C-@ or C-SPC
abort partially typed or executing command C-g exchange point and mark C-x C-x
uppercase word M-u
recover a file lost by a system crash M-x recover-file set mark arg words away M-@ lowercase word M-l
undo an unwanted change C-x u or C-_ mark paragraph M-h capitalize word M-c
restore a buffer to its original contents M-x revert-buffer mark page C-x C-p uppercase region C-x C-u
redraw garbaged screen C-l mark sexp C-M-@ lowercase region C-x C-l
mark function C-M-h
mark entire buffer C-x h The Minibuffer
Incremental Search
The following keys are defined in the minibuffer.
search forward C-s Query Replace
search backward C-r complete as much as possible TAB
regular expression search C-M-s interactively replace a text string M-% complete up to one word SPC
reverse regular expression search C-M-r using regular expressions M-x query-replace-regexp complete and execute RET
select previous search string M-p show possible completions ?
Valid responses in query-replace mode are fetch previous minibuffer input M-p
select next later search string M-n
exit incremental search RET replace this one, go on to next SPC fetch later minibuffer input or default M-n
undo effect of last character DEL replace this one, don’t move , regexp search backward through history M-r
abort current search C-g skip to next without replacing DEL regexp search forward through history M-s
replace all remaining matches ! abort command C-g
Use C-s or C-r again to repeat the search in either direction. back up to the previous match ^ Type C-x ESC ESC to edit and repeat the last command that
If Emacs is still searching, C-g cancels only the part not done. exit query-replace RET used the minibuffer. Type F10 to activate the menu bar using
c 1997 Free Software Foundation, Inc. Permissions on back. v2.2
enter recursive edit (C-M-c to exit) C-r the minibuffer.
GNU Emacs Reference Card Regular Expressions Registers
any single character except a newline . (dot) save region in register C-x r s
Buffers zero or more repeats * insert register contents into buffer C-x r i
one or more repeats + save value of point in register C-x r SPC
select another buffer C-x b zero or one repeat ? jump to point saved in register C-x r j
list all buffers C-x C-b quote regular expression special character c \c
kill a buffer C-x k alternative (“or”) \|
grouping \( . . . \) Keyboard Macros
Transposing same text as nth group \n
at word break \b start defining a keyboard macro C-x (
transpose characters C-t not at word break \B end keyboard macro definition C-x )
transpose words M-t entity match start match end execute last-defined keyboard macro C-x e
transpose lines C-x C-t line ^ $ append to last keyboard macro C-u C-x (
transpose sexps C-M-t word \< \> name last keyboard macro M-x name-last-kbd-macro
buffer \‘ \’ insert Lisp definition in buffer M-x insert-kbd-macro
class of characters match these match others
Spelling Check explicit set [ ... ] [^ . . . ] Commands Dealing with Emacs Lisp
word-syntax character \w \W
check spelling of current word M-$
character with syntax c \sc \Sc eval sexp before point C-x C-e
check spelling of all words in region M-x ispell-region
check spelling of entire buffer M-x ispell-buffer eval current defun C-M-x
International Character Sets eval region M-x eval-region
read and eval minibuffer M-:
Tags specify principal language M-x set-language-environment load from standard system directory M-x load-library
show all input methods M-x list-input-methods
find a tag (a definition) M-.
find next occurrence of tag C-u M-.
enable or disable input method C-\ Simple Customization
set coding system for next command C-x RET c
specify a new tags file M-x visit-tags-table show all coding systems M-x list-coding-systems customize variables and faces M-x customize
regexp search on all files in tags table M-x tags-search choose preferred coding system M-x prefer-coding-system
run query-replace on all the files M-x tags-query-replace Making global key bindings in Emacs Lisp (examples):
continue last tags search or query-replace M-, (global-set-key "\C-cg" ’goto-line)
Info (global-set-key "\M-#" ’query-replace-regexp)
Shells enter the Info documentation reader C-h i
find specified function or variable in Info C-h C-i Writing Commands
execute a shell command M-!
Moving within a node:
run a shell command on the region M-| (defun command-name (args)
filter region through a shell command C-u M-| scroll forward SPC "documentation" (interactive "template")
start a shell in window *shell* M-x shell scroll reverse DEL body)
beginning of node . (dot)
An example:
Rectangles Moving between nodes:
(defun this-line-to-top-of-window (line)
next node n "Reposition line point is on to top of window.
copy rectangle to register C-x r r previous node p With ARG, put point on line ARG."
kill rectangle C-x r k move up u (interactive "P")
yank rectangle C-x r y select menu item by name m (recenter (if (null line)
open rectangle, shifting text right C-x r o select nth menu item by number (1–9) n 0
blank out rectangle C-x r c follow cross reference (return with l) f (prefix-numeric-value line))))
prefix each line with a string C-x r t return to last node you saw l
return to directory node d The interactive spec says how to read arguments interac-
go to any node by name g tively. Type C-h f interactive for more details.
Abbrevs
Other: c 1997 Free Software Foundation, Inc.
Copyright
add global abbrev C-x a g run Info tutorial h v2.2 for GNU Emacs version 21, 1997
add mode-local abbrev C-x a l designed by Stephen Gildea
quit Info q
add global expansion for this abbrev C-x a i g search nodes for regexp M-s Permission is granted to make and distribute copies of this card pro-
vided the copyright notice and this permission notice are preserved on
add mode-local expansion for this abbrev C-x a i l
all copies.
explicitly expand abbrev C-x a e
For copies of the GNU Emacs manual, write to the Free Software Foun-
expand previous word dynamically M-/
dation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

You might also like