GNU Emacs Manual - Other Repeating Search
Node: Other Repeating Search
Prev: Replace
Up: Search
Other Search-and-Loop Commands
Here are some other commands that find matches for a regular expression. They all operate from point to the end of the buffer.
-
M-x occur RET regexp RET
-
Display a list showing each line in the buffer that contains a match for regexp. A numeric argument specifies the number of context lines to print before and after each matching line; the default is none. To limit the search to part of the buffer, narrow to that part (see Narrowing).
The buffer `*Occur*' containing the output serves as a menu for finding the occurrences in their original context. Click Mouse-2 on an occurrence listed in `*Occur*', or position point there and type RET; this switches to the buffer that was searched and moves point to the original of the chosen occurrence.
-
M-x list-matching-lines
-
Synonym for M-x occur.
-
M-x count-matches RET regexp RET
-
Print the number of matches for regexp after point.
-
M-x flush-lines RET regexp RET
-
Delete each line that follows point and contains a match for regexp.
-
M-x keep-lines RET regexp RET
-
Delete each line that follows point and does not contain a match for regexp.
Up: Search