4 Great line commands
4 helpful line commands
flush-lines
Delete lines containing matches for REGEXP
Works from point onwards, i.e. match must follow point
One can use it to operate on regions
Lines are deleted not copied to kill ring
For case senstive flushing one must set the variable search-upper-case
to non-nil
One can call the command interactively in which case the number of deleted lines is printed
Especially useful for deleting blank lines in a buffer
kill-matching-lines
This will not just delete the lines but add them to the kill ring too.
This is a great way to move common lines.
One can use it for example to organize files containing common data.
keep-lines
Delete all lines except those containing matches for REGEXP
Operates on the text after point.
Also operates on regions, but region must include the whole line for it to be effective.
Matches split across lines are NOT deleted.
M-x copy-matching-lines
Just like kill-matching-lines
except the lines are copied not killed