Notes and keyboard shortcuts/commands for Emacs with Slime.
C is control. C-x C-x means hold down control and press x twice.
M is meta (alt).
E is escape.
Documentation
Key binding |
Action |
C-h |
View list of help commands |
C-h b |
View list of keyboard shortcuts available for the current buffer |
Files, buffers and windows
Key binding |
Action |
C-x C-f |
Open (find) file |
C-x k |
Close buffer |
C-x 5 2 |
Open new window |
C-x C-s |
Save file |
C-x 2 |
Split window horizontally |
C-x 3 |
Split window vertically |
C-x 1 |
Remove splits |
C-x o |
Switch windows |
C-x b return |
Switch buffers (defaults to next buffer, up/down to scroll) |
C-x C-c |
Quit emacs |
C-g or Esc Esc Esc |
Exit command input |
Command control
Key binding |
Action |
C-x z |
Repeat last command. You can press z as many times as you’d like |
C-u [N] [C] |
Execute command [C] multiple [N] times. E.g. C-u 8 * inserts asterix eight times |
Editing
Key binding |
Action |
C-x u |
Undo edit |
C-x u C-x u |
Redo edit (Note that an undo is added to action history, so to redo you undo the undo!) |
C-_ |
Redo edit (only works in some environments) |
M-x revert-buffer |
Undo all changes |
C-a |
Start of line |
C-k |
Delete line starting at cursor |
C-space |
Set mark |
C-w |
Cut |
M-w |
Copy |
C-y |
Paste |
A note about undos. They are added to the command stack so if you undo twice then the second undo undoes the last undo. See How do you ‘redo’ changes after ‘undo’ with Emacs?
Navigation and search
Key binding |
Action |
C-f |
Forward one character |
C-b |
Backward one character |
M-f |
Forward one word |
M-b |
Backward one word |
C-s |
Search forward |
C-r |
Search backward |
C-g |
Return to where search started (if you are still in search mode) |
M-% |
Query replace |
Slime
If any of these shortcuts/commands aren’t working, try adding (slime-setup '(slime-fancy slime-asdf))
to your .emacs file (see Introduction to SLIME.
Documentation
Key binding |
Action |
M-. |
Jump to definition of function under cursor |
M-, |
Jump back |
Hit spacebar after function |
Show function arguments |
C-c C-d d when on symbol |
Show symbol definition |
C-c C-d h when on symbol |
Open symbol definition from CL hyperspec in browser |
Compilation and messages
Key binding |
|
M-x slime |
Start slime |
M-x slime-restart-inferior-lisp |
Restart lisp |
C-c C-c |
Compile current form |
C-c C-k |
Compile current buffer |
M-n |
Step forward through annotations post compilation |
M-p |
Step backward through annotations post compilation |
C-c M-c |
Clear annotations |
Navigate to message and hit return |
In REPL, show annotation (aka mark) |
C-up or C-down |
Move up/down through command history |
Debugging (from the REPL)
Key binding |
Action |
C-c I |
Start the inspector. (See inspector below for more info) |
, |
Enter command, e.g. help |
tab |
Command completion. (See command completion below for more info) |
C-up/down |
Command history navigation |
E-p/n |
Command history navigation (alternative). Think p for previous and n for next |
Command completion
Slime’s command completion, started with tab
from the REPL, can complete over the entire set of characters, e.g. if you type m-v- and hit tab it’ll change it to multiple-value and open a new frame showing which commands are available that start with those characters.
Note: Hitting tab alone may use emacs tab completion (for anything you’ve already typed into the buffer) rather than slime completion. If this is the case, then use C-c tab instead.
Inspector
Start the inspector via C-c I
from the REPL. It will prompt you for a list expression to inspect. You can navigate the inspector and drill up/down the objects to read more about them.
Key binding |
Action |
C-h b |
View all available inspector shortcut commands |
Up/down/left/right |
Move cursor |
Return |
Inspect next object, i.e. inspect object under the cursor |
n |
Inspect next object (alternative). Think n for next |
l |
Inspect last object, i.e. go to previous page. Think l for last |
For example, try (find-package 'common-lisp)
in the inspector. Navigate to ‘978 present symbols’ and hit return to view available symbols, then hit return on ‘[Group by classification]’ and you’ll see a list of bound symbols followed by a list of all classes, constants, functions, etc.
References