5

In an emacs buffer when editing a file called "log/development.log" how do I quickly remove all lines containing the word "Render"

12

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.

  • 1
    M-< (beginning-of-buffer) also works. And I think its alias delete-matching-lines is easier to remember for me. – xuchunyang Mar 22 '18 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.