In an emacs buffer when editing a file called "log/development.log" how do I quickly remove all lines containing the word "Render"
Asked
Active
Viewed 9,520 times
1 Answers
32
You can go to beginning of buffer with M-<
, then M-x flush-lines
, type your word and hit RET
.
(flush-lines REGEXP &optional RSTART REND INTERACTIVE)
Delete lines containing matches for REGEXP. When called from Lisp (and usually when called interactively as well, see below), applies to the part of the buffer after point. The line point is in is deleted if and only if it contains a match for regexp starting after point.
flush-lines
also has an alias ,delete-matching-lines
which might be easier to remember for you.
You also have keep-lines
(alias delete-non-matching-lines
), which deletes all of the non-matching lines, keeping only those that match.
M-<
(beginning-of-buffer
) also works. And I think its aliasdelete-matching-lines
is easier to remember for me. – xuchunyang Mar 22 '18 at 17:27C-s M-o
emacs will summarize all matched lines in another buffer for me, but this is a different command withM-x flush-lines
, and I have to type the regex twice which may introduce typo. This is why I want a confirmation list. – Daniel Mar 17 '23 at 04:36