Emacs: List/Delete Matching Lines
- Alt+x
list-matching-lines
【Alt+s o】 (alias ofoccur
) - List all lines in the current file that matches a Regex text pattern.
- Alt+x
copy-matching-lines
- Copy lines that matches a regex pattern.
- Alt+x
count-matches
-
Count matching lines.
(alias of
how-many
) - Alt+x
kill-matching-lines
- Copy and delete matching lines
- Alt+x
delete-matching-lines
-
Delete lines that match a Regex. Works on text selection or starts at the line your cursor is on. (alias of
flush-lines
) - Alt+x
delete-non-matching-lines
-
(alias of
keep-lines
) - Alt+x
delete-duplicate-lines
- Delete duplicated lines in text selection.

Clicking the line jumps to the match location.
Escape Regex Chars
All these commands use Emacs: Regular Expression to search. So, if you simply want to search plain words or phrases, and if your phrase contains any special regex characters, you need to escape them.
Here's common regex special characters that need backslash before to be considered literal:
. + * \ ? [ ]
Letter Case Sensitivity
List Lines in ALL Buffers
Alt+x multi-occur
if you want to list lines in ALL buffers.