GNU Emacs Quick Reference Guide for CS61B
M-d
Bullets () mark a suggested starting set of commands. Daggers (y) denote key bindings that are not standard in GNU Emacs. ARG denotes the prefix numeric argument (entered with C-u or M-digit).
C-k M-W M-n M-SPC C-x C-o C-M-w
Cursor motion. C-f M-f C-e C-b M-b C-a M-e M-[ M-a M-]
C-y C-u C-y
Forward character. Forward word. Forward to end of line. Backward character. Backward word. Backward to start of line. Forward sentence. Forward paragraph. Backward sentence. Backward paragraph.
M-y M-w
TAB LF M-; M-LF C-x TAB C-M-n
Indent according to mode. Same as RET TAB. Indent and start comment. Continue comment on next line. Indent region rigidly by ARG. Indent region according to mode.
Search C-s C-s C-r C-r C-u M-x M-x M-x
Marking regions of text Set mark at point. Exchange mark and point. Same as C-@. Set mark after end of next word. Set mark and point around current paragraph. Set mark and point around current buffer.
Search forward. Same as C-s with last string. Search backward. C-r Same as C-r with last string. C-s Search forward for regular expression. occur Display lines matching a regular expression. grep Display results of UNIX grep utility. count-matches C-s
The following subcommands are valid during a search. RET DEL C-g C-s C-r C-q C-w LFD
Deletion and yanking DEL M-DEL C-d
Insert text from kill buffer at point. Insert text from kill buffer at point without moving point. Replace preceding C-y text with next most recent kill buffer. Copy region to kill buffer, no deletion.
Indentation
C-n Next line. C-p Previous line. M-< Beginning of buffer. M-> End of buffer. C-v Scroll text up one screen (or ARG lines). M-v Scroll text down (or ARG lines). M-g Go to line number ARG.y M-x what-line Display line number. C-M-v Scroll other window up one screen (or ARG lines).
C-@ C-x C-x C-SPC M-@ M-h C-x h
Delete word at and after cursor and add to kill buffer. Delete to end of line and add to kill buffer. Delete current region, and add to kill buffer.y Delete surrounding blanks and tabs. Delete all but one surrounding blank. Delete all but one surrounding blank line. Cause next command, if a kill, to append to previous kill buffer, instead of new one.
Delete character before cursor. Delete word before cursor and add to kill buffer. Delete character at cursor.
22
End search. Undo effect of last search character typed. Abort search. Search for next match forward. Search for next match backward. Quote next character. Extend search string with next word. Extend search string with rest of line.
Replacement
Files
M-q Query replace.y M-Q Query replace regular expression.y M-x delete-matching-lines M-x delete-non-matching-lines
C-x C-x C-x C-x C-x M-x
C-f Find file; load if needed. 4 C-f Find file in other window. C-s Save file. C-w Write to explicitly-named file. i Insert file at cursor. recover-file Recover file after disaster from auto-save file. M-x revert-buffer Throw away changes to buffer and restore from file.
During a query-replacement, the following are valid responses to prompts. SPC DEL RET ! C-r
Make replacement and go to next. Skip replacement and go to next. End replacement. Replace all remaining instances without asking. Enter recursive edit; return with C-M-c.
Buffers and windows C-x C-x C-x C-x C-x C-x C-x C-x
Regular expressions . Λ $ [...] [Λ...] * + ? nc nb nB nj n(...n)
nn
Match any character. Match at start of line. Match at end of line. Match any character in the β...β. Match any character except those in β...β. Match 0 or more of pattern to left. Match 1 or more of pattern to left. Match 0 or 1 of pattern to left. Quotes c, except for the following. Match at beginning or end of word. Match except at beginning or end of word. Match either pattern to left or right. Grouping. Match copy of whatever matched nth group.
Put cursor in other window. Grow current window to full screen. Split current window vertically. Put named buffer in window. Remove current window. Split current window horizontally. List all buffers. Delete buffer.
Shells M-x shell Run UNIX shell in a buffer. M-j Execute single shell command on region. With ARG, replaces region. Commands active in shell buffers: RET TAB C-c C-c C-c C-c
Miscellaneous editing C-o C-t M-t C-x C-t M-u M-l M-c
o 1 2 b 0 3 C-b k
Insert newline after cursor. Transpose characters. Transpose words. Transpose lines. Convert whole word to upper case. Convert whole word to lower case. Capitalize word.
C-c C-u C-z C-d
Send current line to shell. Complete preceding file name. Send interrupt to shell. Erase current input line. Send stop signal to shell. Send EOF to shell.
Compilation, debugging, and tags M-x compile Execute command (by default, make) asynchronously. C-x β Position to next error or next line found by M-x grep command. M-x kill-compiler Stop active compile.
23
M-x visit-tags-table Specify file containing tags produced by etags. M-. Display source for given tag. C-u M-. Find next alternate definition for last tag. C-x 4 . Display source for tag in other window. M-x tags-search M-x tags-query-replace Look for pattern in all files named in tags table. M-x tags-apropos Display matching tags. M-x gdb M-x gjdb
Run GNU debugger on file. Run Java debugger on class.
Commands valid in gdb and gjdb modes. C-c C-c C-c C-c C-c C-x C-c
C-s C-n < > C-r SPC C-i
Step. Next. Up stack. Down stack. Finish. In any source file, sets a break point. Stepi (gdb only).
Help and documentation M-x C-h C-h C-h C-h C-h C-h C-h C-h C-h
manual-entry UNIX man page for given topic. a Look up names of matching commands. b Display key bindings. f Help for M-x function. C-h Help for C-h. i Run info browser. k Help for key. m Help for current mode. t Tutorial. w Key containing function.
Inside an *info* buffer (result of C-h i), the following are defined. m l ? u n q . d
Select menu item. Go to last-visited node. Get help for browser. Go to nodeβs parent. Go to next node in sequence. Leave browser. Go to top of node. Go to top-level node.
24
Mouse commands Left, middle, and right buttons are LB, MB, and RB. LB Put cursor at mouse. Dragging marks region. MB Paste text from window-system cut buffer at mouse. RB Extend region to pointer and copy into cut and kill buffers. Clicking twice deletes region. C-LB Select a buffer.