Emacs Cheat Sheet

SO Answers

RPT Notes

x b ( switch-to-buffer )
This command reads a buffer name using the minibuffer. Then it makes that buffer current, and displays it in the currently-selected window. An empty input specifies the buffer that was current most recently among those not now displayed in any window.
x column-number-mode
Shows the Column Number
x k ( kill-buffer )
Kills one buffer, whose name you specify in the minibuffer. The default, used if you type just <RET> in the minibuffer, is to kill the current buffer.
o ( open-line )
Insert a blank line after the cursor
x o ( delete-blank-lines )
Delete all but one of many consecutive blank lines
indent-tabs-mode nil
all indentation can be made from spaces only.
x make-local-variable <RET> var <RET>
Make variable var have a local value in the current buffer.
x kill-local-variable <RET> var <RET>
Make variable var use its global value in the current buffer.
x make-variable-buffer-local <RET> var <RET>
Mark variable var so that setting it will make it local to the buffer that is current at that time.

Starting emacs

> emacs [Enter]
to start emacs.
> emacs filename [Enter]
to start emacs and load a file
> emacs -nw filename [Enter]
to start emacs with no new window (load file)


[Ctrl]X [Ctrl]C
quit emacs (Can be used with impunity -- the system will prompt if the workspace has not yet been saved.)
aborts any command in progress


[Ctrl]H T
to see the tutorial
[Ctrl]H A topic [Enter]
to see help about topic
[Ctrl]X U
undo the last command

Cursor Positioning

[Ctrl]F or [>-]
forward (right) one character.
[Ctrl]B or [>-]
back (left) one character
[Ctrl]P or [^]
up one character
[Ctrl]N or [v]
down one character
left one word
right one word
to beginning of line
to end of line
start of document
end of document
page up
page down
cursor in middle of screen
[Ctrl]U 20 [Ctrl]N
advance 20 lines
[Ctrl]x w
display the line number where the cursor is located
[Esc]X goto-line [Enter] 999 [Enter]
go to line number 999

Search and Replace

[Ctrl]S patterntext [Enter]
search for patterntext; cursor moves as you type. Press [Enter] once at the correct location
[Ctrl]R patterntext [Enter]
search backwards for patterntext; cursor moves as you type.
[Ctrl]S [Enter] [Enter]
search for the next occurrence
[Esc]% oldstring [Enter] newstring [Enter]
Search for oldstring and replace it with newstring. The Y key confirms each replacement, N skips it, Q to exit


set mark at cursor
kill region
copy region to kill ring
yank back last thing killed

Loading and Saving

[Ctrl]X [Ctrl]F filename
create new filename for editing (clears workspace)
[Ctrl]X [Ctrl]F filename
load in filename for editing
[Ctrl]X [Ctrl]W filename
write (save) as filename
[Ctrl]X [Ctrl]S
resave under the current filename (based on above or name given when starting emacs)

Common Lisp

[Ctrl]X L
start Common Lisp lisp image

©1997 Fernando Lopez-Lezcano. All Rights Reserved.