Computer Science 010

Emacs Cheat Sheet

Cursor Motion Commands:

C-f

Forward one character

C-b

Backward one character

C-n

Next line

C-p

Previous line

C-a

Beginning of line

C-e

End of line

C-v

Next screenful

M-v

Previous screenful

M-<

Beginning of buffer

M->

End of buffer

C-s

Search forward incrementally

C-r

Reverse search incrementally

C-x C-x

Swap mark and cursor

   

Editing Commands

C-d

Delete next character

Backspace

Delete previous character

M-x replace-string

Global string replacement

M-%

Query string replacement

M-d

Delete next word

C-k

Kill to end of line (delete to end of line)

C-w

Cut region

M-w

Copy region

C-y

Yank most recent cut/copy (paste command)

M-y

Replace yanked text with previously cut/copy text (only works immediatly after C-y or another M-y)

   

File Commands

C-x C-f

Open a file

C-x C-s

Save buffer to file

M-x revert-buffer

Throw out all changes and revert to the last saved version of the file.

Buffer Commands

C-x b <buffer name>

Replace the current buffer with the one with the given name

C-x 1

Make the current buffer be the only buffer

C-x 2

Split the current buffer into two buffers

Help Commands

C-h i

Info

C-h a

Apropos

C-h b

Key bindings

C-h m

Mode help

C Mode Commands

C-j

Insert a newline and indent the next line.

C-c C-q

Fix indentation of current function

C-c C-a

Toggle the auto-newline-insertion mode. (If it was off, it will now be on and vice versa.)

C-c C-d

Toggle the hungry delete mode

M-x c-set-style

Change the indentation style

Compilation Mode Commands

<return> on an error message

Scrolls the error to the top of the buffer and displays the C file containing that error in a second buffer, pointing to the line with the error

Miscellaneous Commands

C-x C-c

Exit Emacs

C-g

Cancel command

C-SPACE

Set mark

C-x u

Undo

M-x gdb

Start the gnu debugger

M-x shell

Start a shell in a new buffer

M-x print-buffer

Send the contents of the current buffer to the printer

M-x compile

Compile a program

M-x set-variable

Change the value of an Emacs variable to customize Emacs


Back to CS 010 Home Page