Emacs Quick-Ref Revision 1.1 Project Athena March, 1984 MIT To Get Into Emacs enter Emacs, edit old or new file filename emacs filename recover editing in progress at system crash emacs -r To Get Out of Emacs leave Emacs, prompts to save buffers C-C C-C or C-X C-Z Command Format Bound Commands [ C-U [+ [n]] ] prefix-character character C-U is usually a repeat count, performing the command n times in the + or - direction. Just C-U is 4. C-U C-U is 16. When C-U is not a repeat count, it is a general switch whose influence varies with each command. Unbound, Extended Commands M-X function nameESCargumentESC...RETURN Emacs will prompt for required arguments. Prefix Characters In Documentation* Name Actual Keys Pressed C-c Control Control-c M-c Meta Escape c C-M c Control-Meta Control-Z c C-X c Control-X Control-X c C-C c Control-C Control-C c C-^c Control-Control Control-~ Control-c C-c ^c Control-c Control-c M-X function Extended Command Escape X function *where c is any character Canceling, Undoing, Exiting undo the last command entered C-C U undo all changes made to this line C-U C-C U cancel any command, get out of things C-G abort a recursive editing level w/o changes C-] exit a recursive editing level normally C-Z Z exit a subsystem, varies with subsystem, try Q Moving the Cursor Unit Action Command character character right or C-F character left or C-B word word right M-F word left M-B right to start-of-word C-C F left to end-of-word C-C B line up or C-P down or C-N jump to start C-A jump to end C-E start of text, current line M-RETURN start of text, previous line C-^P start of text, next line C-^N go to line n C-U n C-C G sentence backward to start M-A forward to end M-E paragraph backward to start M-[ forward to end M-] screen next C-V previous M-V n screens forward C-U n C-X V cursor to top left corner C-C H buffers jump to start M-< jump to end M-> mark exchange cursor with mark C-X C-X see also Searching Inserting Text normal printing characters just type blank lines RETURN RETURN control characters C-Q control-char text from other buffer M-X Insert Buffer text from external file C-C I filename Help ask for general help, then follow instructions C-? (C-G to exit) Deleting and Killing Unit Action Command character delete previous character DELETE key delete current character C-D word kill word forward M-D kill word backward M-DELETE lines kill line forward C-K kill line backward C-U 0 C-K kill line containing string C-^F sentences kill sentence forward M-K kill sentence backward C-X DELETE paragraphs kill paragraph forward C-C C-K kill paragraph backward C-C DELETE region kill region C-W anystring kill (zap) forward to c M-Z c kill (zap) backward to c C-U - M-Z c Yanking (Undeleting) Text Yank back (restore) last thing deleted C-Y undo all changes made to this line C-U C-C U Marking a Region A region is all the text between a mark and the cursor. Arbitrary region 1. Place cursor at beginning of region. 2. Set mark with C-spacebar Mark appears in reverse video. 3. Move cursor to end of region. word mark M-@ sentence mark C-X @ paragraph mark M-H buffer mark C-X H Searching 1. Start search forward to end of buffer C-S backward to start of buffer C-R 2. Emacs prompts for search string, then finds it incrementally as you enter it. Fix typos with DELETE key. 3. While in search mode, these commands are valid: to end search C-D to look for next occurrence C-S to cancel search C-G to reverse direction of search C-S or C-R print all lines containing string C-C O string (spacebar to continue) Replacing Replace every occurrence of string1 with string2 after cursor M-X Replace StringESCstring1ESCstring2RETURN Query Replace some occurrences of string1 with string2 after cursor 1. M-R 2. Emacs prompts for From: string1 C-D prompts for To: string2 C-D 3. Emacs finds each occurrence and prompts for action. Valid actions replace that occurrence spacebar skip to next w/o changing DELETE key replace this and display result comma key replace this one, then exit period key exit without doing anymore C-D replace all the remaining w/o prompting ! go back to the previous one ^ enter recursive editing mode C-R (C-M Z to exit) exit any other character restart query-replace with same strings C-C R Notes: There is no reverse direction replace. The search is indifferent to case unless C-C VCase Search is set to 0. If string2 is entered in all lowercase, it will match the case of its replacement string1. Otherwise it is as-entered. Copy and Move Text 1. Mark the text to be moved or copied as a region. 2. Kill that region with C-W 3. If text is to be copied, immediately yank it back with C-Y. 4. Move to destination. Yank text with C-Y. Simple Text Formatting to set right margin to column n C-U n C-X F to turn on or off auto fill mode M-X Auto Fill Mode (toggle, off by default) fill paragraph M-Q justify paragraph C-U n M-Q fill region M-G justify region C-U n M-G center text on line w/respect to fill M-S Buffers create create a new buffer C-X B buffername create a new buffer and read in the contents of a file C-X C-F filename move around select a different buffer C-X B buffername list all existing buffers C-X C-B (space to continue) delete delete a buffer C-X K buffername Files read read file into current buffer destroying current contents, visit C-X C-V filename read file into current buffer, prompt to save old contents C-X C-R filename insert file into current buffer, at cursor, old contents not changed C-C I filename write save current buffer into same file C-X C-S save current buffer into different file (write) C-X C-W filename save marked region as a file C-^W filename Windows create split window in two horizontally, move to other window C-X 2 split window in two vertically, move to other window C-C 2 split window in two horizontally, stay in same window C-X 3 split window in two vertically, stay in same window C-C 3 split window horizontally, and prompt for buffer, file, or tagfile name C-X 4 split window vertically, and prompt for buffer, file, or tagfile name C-C 4 move move to other window (last one you were in) C-X O ("oh") move to window n C-U n C-X O scroll other window up C-Z V scroll other window down C-U - C-Z V grow window up C-X ^ grow window down C-X LINEFEED grow window right C-C < grow window left C-C > delete kill the current horizontal window C-X 0 ("zero") kill the current vertical window C-C 0 return to one window mode, horizontal C-X 1 return to one window mode, vertical C-C 1 (if prefaced with C-U n, then n will be the window remaining) Linda B. Merims Copyright 1984 Massachusetts Institute of Technology