Computer

emacs cheat sheet

steloflute 2014. 5. 3. 20:02

Original: http://www.rgrjr.com/emacs/emacs_cheat.html

 

UNDO: C-_ ("control underscore") or C-/
Find (or Create) file: C-x C-f
Save file: C-x C-s
Exit Emacs: C-x C-c
Quit (i.e. interrupt) command: C-g

Kill buffer: C-x k

 

Cursor
Motion
Operation
Move Delete
Amount forward backward forward backward
Characters C-f C-b C-d DEL
Words M-f M-b M-d M-DEL
Lines C-n C-p C-k (to EOL) C-SPC C-a C-w
End/start of line C-e C-a (repeat count goes to following lines)
End/start of buffer M-> M-< (no repeat count)
Cutting and Pasting
C-SPC Mark one end of region
C-w Cut (after you Mark and move to other end)
M-w Copy (after you Mark and move to other end)
C-y Yank (paste) most recently killed (cut or copied); will also use text currently selected in another application.
M-y Next most recently killed (do C-y first, repeat M-y to cycle thru all)

 

Scrolling and Windows
C-v Scroll down (toward end of buffer)
M-v Scroll up (toward beginning of buffer)
C-M-v Scroll other window down
C-x 1 One window on current buffer
C-x 2 Split window vertically
C-x 3 Split window horizontally
C-x ^ Grow window vertically; prefix is number of lines
Command-related Stuff
ESC ESC ESC Get me out of where I am now
C-u # Prefix numeric arg # (digits with optional "-" sign) to next cmd
C-g Stop a command in progress, or quit out of a partially entered command
Getting help
C-h k Show command documentation; prompts for keystrokes
C-h a "Command apropos"; prompts for regexp and shows all matching commands
C-h c Show command name on message line; prompts for keystrokes
C-h f Describe function; prompts for command or function name, shows documentation in other window
C-h i Info browser; gives access to online documentation for emacs and more
Miscellaneous
C-_ or C-x u Undo/redo (a series of these keeps undoing; after doing something else, C-_ or C-x u will undo the undo's)
C-q Quoted insert; inserts the next character typed, even if it is a control or meta character
M-x shell-strip-ctrl-m RET Flush ^M at end of line
C-z Suspend/iconify emacs (type "%emacs" in invoking shell to get it back)
C-x C-c Exit emacs (asks about unsaved buffers and running programs)
Files and Buffers
C-x C-f Find file (or create if not there); prompts for file name
C-x C-s Save file
C-x C-w Write file; prompts for new name
C-x s Save modified buffers; asks about each
C-x b Select buffer; prompts for buffer name
C-x C-b List buffers; shows in other window
Searching/Replacing
C-s Incremental search forward; searches as you type
C-r Incremental search backward
M-x replace-string RET String replace from here to end of buffer; prompts for string and replacement
M-x query-replace RET String replace from here to end of buffer, querying for each occurrence