Useful Emacs Commands
This page serves as on-line documentation for some Emacs commands that I always have a hard time remembering. It evolved from “notes to myself” posts on my blog Irreal.
Commands for Matching Lines
COMMAND | ALIAS | ACTION |
---|---|---|
keep-lines | delete-non-matching-lines | Delete lines not matching regexp |
flush-lines | delete-matching-lines | Delete lines matching regexp |
how-many | count-matches | Count lines matching regexp |
occur | list-matching-lines | Show lines matching regexp in another buffer |
highlight-lines-matching-regexp | hi-lock-line-face-buffer | Highlight lines matching regexp |
multi-occur | Occur on multiple buffers | |
multi-occur-in-matching-buffers | Occur on buffers chosen by regexp |
Deleting Lines and Parts of Lines
KEY SEQUENCE | ACTION |
---|---|
【Ctrl+0 Ctrl+k】 | Delete from point to beginning of line |
【Shift+Ctrl+Backspace】 | Delete entire line the point is on |
Miscellaneous Text Commands
KEY SEQUENCE | COMMAND | ACTION |
---|---|---|
【Meta+o Meta+s】 | center-line | Center line (n lines with prefix n) |
【Ctrl+Meta+w】 | append-next-kill | Append next kill |
none | linum-mode | Turn on line numbers in left fringe |
Register Commands
Specify a prefix on copy/move commands to delete the original.
KEY SEQUENCE | FUNCTION |
---|---|
【Ctrl+x r Space ρ】 | Copy position to register ρ |
【Ctrl+x r j ρ】 | Jump to the position in register ρ |
【Ctrl+x r s ρ】 | Copy/Move region to register ρ |
【Ctrl+x r i ρ】 | Insert object in register ρ at point |
【Ctrl+x r r ρ】 | Copy/Move rectangle to register ρ |
【Ctrl+x r w ρ】 | Copy current frame configuration to register ρ |
【Ctrl+x r f ρ】 | Copy all frame configurations to register ρ |
【Ctrl+u N Ctrl+x r n ρ】 | Insert N into register ρ |
【Ctrl+u I Ctrl+x r + ρ】 | Increment register ρ by I |
Using set-mark-command
to Remember Locations
KEY SEQUENCE | ACTION |
---|---|
【Ctrl+Space Ctrl+Space】 | Push current position onto mark ring |
【Ctrl+u Ctrl+Space】 | Return to previous position in the same buffer |
【Ctrl+x Ctrl+Space】 | Return to previous position, which may or may not be in the same buffer |
Useful Help Commands
Command | Action |
---|---|
【e】 | View *Messages* buffer |
【F】 CMD | View Info node documenting CMD |
【r】 | View Emacs Manual |
Also: elisp-index-search
and emacs-index-search
Emacs Syntax Table
These aren't really commands but I always have a hard time finding this table in the built-in documentation so I'm listing it here.
SYNTAX CLASS | CHARACTER DESIGNATION |
---|---|
Whitespace Character | - (hyphen) or ␠ |
Word Constituent | w |
Symbol Constituent | _ (underscore) |
Punctuation Character | . |
Open Parenthesis | ( |
Close Parenthesis | ) |
String Quote | " |
Escape-Syntax Character | \ |
Character Quote | / |
Paired Delimeter (TeX $) | $ |
Expression Prefix | ' |
Comment Starter | < |
Comment Ender | > |
Inherit Standard Syntax | @ |
Generic Comment Delimiter | ! |
Generic String Delimiter | | |