Working With Matching Lines In Emacs

This is another note to myself. For some reason I have a hard time remembering the handful of commands that do things to the lines in a buffer that match a regular expression. The table below are the ones that I know about but have a hard time remembering. If you have any similar commands that you find useful, leave a comment.

Command Alias Action
keep-lines delete-non-matching-lines Delete lines not matching regexp
flush-lines delete-matching-lines Delete lines matching regexp
how-many count-matches Count lines matching regexp
occur list-matching-lines Show lines matching regexp in another buffer
highlight-lines-matching-regexp hi-lock-line-face-buffer Highlight lines matching regexp

Update Phil reminds me of highlight-lines-matching-regexp, which I meant to include but forgot. (See what I mean?) He also mentions multi-occur (just like occur but it acts on multiple buffers) and multi-occur-in-matching-buffers (like multi-occur but you specify the buffers with a regexp), which he says he finds particularly useful.

This entry was posted in General and tagged . Bookmark the permalink.