Jim Brooks
emacs reference card
C-X means to hold down Control key then press key X
M-X means to hold down Meta key (usually Alt) then press key X
ESC X means to press and release ESC key first, then key X
-------------------------------------------------------------------------------
keys
-------------------------------------------------------------------------------
M-k
Kill (delete) paragraph.
C-y [M-y...]
Yank from item in kill ring. Then M-y cycles thru previous items in kill ring.
C-x n n
Narrow view to region.
C-x n w
Exit narrow view.
-------------------------------------------------------------------------------
searching, replacing
-------------------------------------------------------------------------------
C-s C-w [C-w...]
Search for the word that the cursor is on.
Press C-w repeatedly to pick up parts of a word separated by underscore.
Then press C-s to start the search.
C-s RETURN C-w
Do a word seach (ignores line breaks, spaces, and punctuation).
ESC C-s or M-C-s
Regular expression (regex) search forward.
To search or replace in multiple files:
Using dired, mark all files by:
| m (XEmacs)
* s (emacs)
(Press 'u' over any CVS/RCS subdir to exclude it)
A global search thru marked files
M-, continue global search
Q global query/replace thru marked files
Replacement is done by regex and is tricky.
Eg to change "st.", write "st[\.]".
-------------------------------------------------------------------------------
bookmarks
-------------------------------------------------------------------------------
http://www.xemacs.org/Documentation/21.5/html/xemacs_13.html
C-x r m RET
Save bookmark for the visited file.
C-x r m (name) RET
Save bookmark by name.
C-x r b (name) RET
Jump to bookmark (if you remember its name).
C-x r l
List bookmarks.
To see help in this context: C-h m
Keys:
'v' jump to bookmark where cursor is on (view bookmark)
M-x bookmark-save
Save bookmarks to file (~/emacs.bmk).
-------------------------------------------------------------------------------
tags
-------------------------------------------------------------------------------
Create a "TAGS" file:
ctags -e --extra=+q `find . -name "*.cc" -or -name "*.h"`
ctags -e -R --extra=+q (Exuberant will recurse into subdirs tagging anything)
ESC ! etags *.cc *.h (from emacs)
ESC x visit-tags-table
To inform emacs after you've updated the "TAGS" file.
M-.
Jump to a tag.
emacs is smart enough to automatically pre-select the tag that
the cursor is over. Otherwise, emacs will prompt for a tag.
M-*
To previous tag.
M-,
To cycle thru tags having the same name.
M-x find-tag-other-window
Split screen and open tag in second window.
http://www.cs.rochester.edu/u/brown/172/tools/etags.html
C-u M-. NAME
Finds the next definition matching NAME.
C-u - M-.
Goes back to the previous tag found.
C-u C-M-. (C-M-. means to press Ctrl + Alt + '.')
Finds the next tag whose name matches the last pattern used.
C-x 4 .
NAME finds the first def matching NAME and displays it in another buffer.
M-x tags-search
Lets you look through the files in the tags table for everything matching a regular expression.
M-x tags-query-replace
Lets you do a query-replace on a regular expression.
M-,
Lets you restart one of the commands above ('tags-loop-continue').
-------------------------------------------------------------------------------
macros
-------------------------------------------------------------------------------
To create a new macro:
C-x (
Begin macro.
C-x )
End macro.
C-x e
Call the last keyboard macro that you defined with C-x (
C-u
Repeat 4 times.
Then to save the macro:
1. Create the macro using "C-x (" and "C-x )".
2. Name the macro using "ESC x name-last-kbd-macro".
3. Open the file that holds emacs macros.
4. Insert the macro definition using "ESC x insert-kbd-macro".
-------------------------------------------------------------------------------
register
-------------------------------------------------------------------------------
C-x r SPC r
Save the location of point in register r (point-to-register).
C-x r j r
Jump to the location saved in register r (register-to-point).
C-x r s r
Copy region into register r (copy-to-register).
C-x r g r
Insert text contents of register r (insert-register).
-------------------------------------------------------------------------------
rectangular editing
-------------------------------------------------------------------------------
C-x r k
kill-rectangle
C-x r y
yank-rectangle
C-x r r
copy-rectangle-to-register
-------------------------------------------------------------------------------
elisp functions
-------------------------------------------------------------------------------
list-colors-display ;; shows colors as blocks
-------------------------------------------------------------------------------
misc
-------------------------------------------------------------------------------
To change fonts (try maximizing/restoring window if font isn't redrawn):
set-default-font 6x12
emacs -font 6x12