In an emacs buffer when editing a file called "log/development.log" how do I quickly remove all lines containing the word "Render"
1 Answer
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.
-
2
M-<
(beginning-of-buffer
) also works. And I think its aliasdelete-matching-lines
is easier to remember for me. Mar 22, 2018 at 17:27 -
How can I make emacs display all matched lines to be deleted for confirmation? This will make the action much safer. I know that if I type
C-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.– DanielMar 17 at 4:36