This is my collection of Emacs tips or commands that I keep around for quick reference. Perhaps someone else will find something they like here.
Download the text (2007.08.18): ↓ emacs-tips.txt
Emacs tips
==========
Time-stamp: <2007-08-18 17:40:08 sjs>
Inside an incremental search:
* C-w pulls in the word under point
* C-y pulls in the rest of the line from point
* M-y yanks the last text from the kill ring
Keybinding Function Description
---------- -------- -----------
==Help
C-h c describe-key-briefly Display the name of the function bound to the given key sequence.
C-h k describe-key Display documentation for the function bound to the given key sequence.
C-h w where-is Display key sequences bound to the given command name.
C-h l view-lossage Display the last 100 keystrokes.
C-h m describe-mode Display documentation on the current major mode.
** C-h after any prefix key will display all available shortcuts under that prefix. **
==General
word-search-{forward,backward} Search for sequences of words across newlines & puncuation.
C-x $ set-selective-display Hide lines indented greater than ARG levels (folding).
follow-mode Scroll windows of the same buffer in harmony.
C-x = what-cursor-position Display details about what's under the cursor.
C-x z repeat Repeat the most recently executed command.
C-x ESC ESC repeat-complex-command Edit and re-evaluate the last complex command (or ARGth command).
list-history-command List commands available for repitition (via repeat-complex-command).
==Mark and point
M-r move-to-window-line nil ARG: Move to the middle of the window.
ARG > 0: Move point to the ARGth line.
ARG < 0: Move point to the |ARG|th line from the bottom.
C-x h mark-whole-buffer Mark the entire buffer.
C-x C-x exchange-mark-and-point Exchange mark and point, reactivating mark if required.
C-SPC set-mark-command Set and activate the mark, C-u C-SPC pops the mark ring.
C-x C-SPC pop-global-mark
A prefix of 0 (C-u 0) has a special meaning for the transpose family of functions. Since it would otherwise be meaningless
it transposes the chars/words/sexps/lines around the region specified by point and mark. It's best to try this one out to
see exactly how it works!
C-t transpose-chars
M-t transpose-words
C-M-t transpose-sexps
C-x C-t transpose-lines
** Mark and point can be treated as a rectangle, and are by certain functions. (see next section) **
==Rectangles
C-x r c clear-rectangle Replace text in the rectangle with spaces, blanking out the region destructively.
C-x r d delete-rectangle Delete text in the rectangle described by mark and point.
C-x r o open-rectangle Shift text in the rectangle right, blanking out the region non-destructively.
C-x r t string-rectangle Replace rectangle contents with the given string.
C-x r y yank-rectangle Yank back the last killed rectangle contents, top-left at point.
==Whitespace / cleaning up
C-x C-o delete-blank-lines Delete all but one of many consecutive blank lines.
fixup-whitespace Clean up space between objects around point.
M-\ delete-horizontal-space Delete all spaces & tabs around point.
M-SPC just-one-space Delete all spaces & tabs around point except for one (or N).
canonically-space-region Remove extra spaces between words in region.
delete-trailing-whitespace Delete all trailing whitespace in the current buffer.
==Shell mode
C-c C-n comint-next-prompt Move point to the next prompt.
C-c C-p comint-previous-prompt Move point to the previous prompt.
C-c RET comint-copy-old-input Copy the command input at point to the end of the buffer.
Variable Description
-------- -----------
track-eol If set next-line and previous-line will move to EOL if moving from EOL.
Slime mode
==========
Keybinding Function Description
---------- -------- -----------
==Compilation
C-c C-k slime-compile-and-load-file Compile and load the current buffer.
C-c M-k slime-compile-file Compile (but don't load) the current buffer.
C-c C-c slime-compile-defun Compile the top-level form at or around point.
M-n slime-next-note Move to the next compiler note.
M-p slime-previous-note Move to the previous compiler note.
C-c M-c slime-remove-notes Remove all annotations from the buffer.
==REPL
C-Return slime-repl-closing-return Close all open parentheses and evaluate the current line.
==Navigation
M-. slime-edit-definition Go to the definition of the symbol at point.
M-, slime-pop-find-definition-stack Go back from the definition found with slime-edit-definition.
==Evaluation
C-M-x slime-eval-defun Evaluate the top-level form.
(ARG inserts result into buffer)
C-x C-e slime-eval-last-expression Evaluate the last expression before point.
(ARG inserts result info buffer)
C-c C-p slime-pprint-eval-last-expression Evaluate the expression before point and pretty-print the result.
C-c C-r slime-eval-region Evaluate the region.
C-c : slime-interactive-eval Evaluate an expression read from the minibuffer.
slime-scratch Create a buffer like Emacs' *scratch*, eval expressions with C-j.
==Programming
C-c M-i slime-fuzzy-complete-symbol Presents a list of likely completions to choose from for an abbreviation
at point.
C-c C-s slime-insert-arglist Look up and insert the arg list for the function at point.
C-c C-m slime-macroexpand-1 Macroexpand the expression at point once. Use a prefix to call macroexpand
instead of macroexpand-1.
C-c C-t slime-toggle-trace-fdefinition Toggle tracing of the function at point.
C-c M-d slime-disassemble-symbol Dissassemble the function definition of the symbol at point.
==Debugging
[TODO clean this up, this is copied from the Emacs wiki]
The following commands invoke restarts:
* 0 .. 9 - Invoke a restart by number.
* q - Throw to the top-level.
* a - Invoke the ABORT restart.
* c - Invoke the CONTINUE restart.
There are also commands for poking around in the frame at point:
* v - Show the current frame's source expression in a buffer.
* t - Toggle verbose display of the frame at point. The verbose version includes all local variables and CATCH tags.
* l - Show local variables.
* e - Evaluate an expression from inside a frame.
* d - Evaluate an expression and display the result in an extra buffer.
* i - Evaluate an expression and inspect the result.
* : - Evaluate an expression (in the global environment).
* D - Disassemble the code of the current frame.
* r - Restart execution of the frame with the same arguments as it was called originally. (Not supported by all backends.)
* R - Return a value from the current frame. (Not supported by all backends.)
Motion between frames:
* n - Move to the next frame.
* p - Move to the previous frame.
* M-n - Detail-move to the next frame. This switches the current frame to a one-line summary, then moves to the next frame, displays it verbosely in the backtrace (as with t), and shows the corresponding source expression (as with v).
* M-p - Detail-move to the previous frame.
==Reference
C-c < slime-who-calls Reveal callers of the function at or around point.
C-c > slime-who-references Reveal references to the global variable at or around point.
C-c C-d is the prefix for the following help commands:
d slime-describe-symbol Describe the symbol at point.
a slime-apropos
z slime-apropos-all Includes internal symbols.
p slime-apropos-package
h slime-hyperspec-lookup Customize with common-lisp-hyperspec-root browse-url-browser-function.
~ common-lisp-hyperspec-format
