apply-macro-to-region-lines

apply-macro-to-region-lines is an interactive autoloaded compiled Lisp function in `macros.el'.

It is bound to C-x C-k r.

(apply-macro-to-region-lines TOP BOTTOM &optional MACRO)

Apply last keyboard macro to all lines in the region.
For each line that begins in the region, move to the beginning of
the line, and run the last keyboard macro.

When called from lisp, this function takes two arguments TOP and
BOTTOM, describing the current region. TOP must be before BOTTOM.
The optional third argument MACRO specifies a keyboard macro to
execute.

This is useful for quoting or unquoting included text, adding and
removing comments, or producing tables where the entries are regular.

For example, in Usenet articles, sections of text quoted from another
author are indented, or have each line start with `>'. To quote a
section of text, define a keyboard macro which inserts `>', put point
and mark at opposite ends of the quoted section, and use
`C-x C-k r' to mark the entire section.

Suppose you wanted to build a keyword table in C where each entry
looked like this:

{ "foo", foo_data, foo_function },
{ "bar", bar_data, bar_function },
{ "baz", baz_data, baz_function },

You could enter the names in this format:

foo
bar
baz

and write a macro to massage a word into a table entry:

\C-x (
\M-d { "\C-y", \C-y_data, \C-y_function },
\C-x )

and then select the region of un-tablified names and use
`C-x C-k r' to build the table from the names.