Notes to Self

Alex Sokolsky's Notes on Computers and Programming

Emacs Customization and Cheat Sheet

Emacs Configuration



Key PC Mac
Meta Esc
DEL DEL (or M-BACKSPACE on some keyboards) DEL
Notation Means
C-x Press and hold the Control key and then press and release the “x” key
M-x Press and release the Meta key and then press the “x” key


Key Command Function
C-x C-c Exit Emacs  

Open/Save File

Key Command Function
C-x C-f Open or create file M-x find-file
C-x C-r Open file in read-only mode  
C-x C-v Replace current opened file  
C-x C-s Save buffer M-x save-buffer
C-x C-w Save file with new name M-x write-file
C-x i Insert another file M-x insert-file

Buffer Commands

Key Command Function
C-x b Switch to another buffer M-x switch-to-buffer
C-x C-b List buffers M-x list-buffer
C-x k Kill current buffer M-x kill-buffer
C-x C-s Save buffer M-x save-buffer
C-l Refresh buffer, cycle mid, bottom, top  


Key Command Function
C-x 2 Split window vertically M-x split-window-vertically
C-x 3 Split window horizontally M-x split-window-horizontally
C-x o Move to another window M-x other-window
C-x 0 Delete the current window M-x delete-window
C-x 1 Delete all windows but the current M-x delete-other-windows

Moving Around

Move By Forward Backward
Char C-f C-b
Word M-f M-b
Sentence M-e M-a
Paragraph M-} M-{
Line C-n C-p
Line End/Start C-e C-a
Buffer End/Start M-> M-<
Scroll C-v M-v
Command Keystroke Function
Move to the beginning of a buffer M-< M-x beginning-of-buffer
Move to the end of a buffer M-> M-x end-of-buffer
Move forward one character C-f M-x forward-char
Move backward one character C-b M-x backward-char
Move down one line C-n M-x next-line
Move up on line C-p M-x previous-line
Move forward one word M-f M-x forward-word
Move backward one word M-b M-x backward-word
Move to the end of a line C-e M-x end-of-line
Move to the beginning of a line C-a M-x beginning-of-line
Move forward one screen C-v M-x scroll up
Move backward one screen M-v M-x scroll-down

Cut/Delete/Kill Text

Command Keystroke Function
Delete character C-d M-x delete-char
Delete previous character DEL M-x delete-backward-char
Delete word M-d M-x kill-word
Delete previous word M-DEL M-x backward-kill-word
Delete the entire line C-k M-x kill-line

Mark Text to Delete, Move or Copy

Command Keystroke Function
Mark the beginning of a selection C-@ or C-SPACEBAR M-x set-mark-command
Delete the marked region C-w M-x kill-region
Copy a marked region M-w or C-INSERT M-x kill-ring-save
Yank a region C-y M-x yank
Command Keystroke Function
Forward C-s M-x isearch-forward
Backward C-r M-x isearch-backward
Cancel C-g M-x keyboard-quit
Delete incorrect character in search string DEL  

Search / Replace Text

Command Keystroke Function
Search forward C-s RETURN  
Search backward C-r RETURN  
Start search and replace M-% M-x query-replace
Replace current instance and continue on to next instance SPACEBAR or y  
Don not replace current instance, move on to next instance DEL  
Replace the current instance and then quit . (period key)  
Replace the current instance and then pause , (comma key)  
Resume after pausing SPACEBAR or y  
Replace remaining instances without asking !  
Back up to previous instance ^  
Exit query replace RETURN (or ENTER on some keyboards) or q  
Command Keystroke Function
Search forward M C-s RETURN FOLLOWED BY thisIsMySearchExpressio* M-x re-search-forward
Search backward M C-r RETURN FOLLOWED BY thisIsMySearchExpressio* M-x re-search-backward
Search forward and incrementally M C-s M-x isearch-forward-regexp
Search backward and incrementally M C-r M-x isearch-backward-regexp

Misc Commands

Command Keystroke Function
Undo C-x u  
Undo all changes since the last save   M-x revert-buffer
Shell   M-x shell
Cancel current command C-g  

Color Theme

Must have Color Theme, e.g. Dracula!