Previous: , Up: Filling   [Contents][Index]


20.6.3 The Fill Prefix

To fill a paragraph in which each line starts with a special marker (which might be a few spaces, giving an indented paragraph), use the fill prefix feature. The fill prefix is a string which is not included in filling. Emacs expects every line to start with a fill prefix.

C-x .

Set the fill prefix (set-fill-prefix).

M-q

Fill a paragraph using current fill prefix (fill-paragraph).

M-x fill-individual-paragraphs

Fill the region, considering each change of indentation as starting a new paragraph.

To specify a fill prefix, move to a line that starts with the desired prefix, put point at the end of the prefix, and give the command C-x . (set-fill-prefix). That’s a period after the C-x. To turn off the fill prefix, specify an empty prefix: type C-x . with point at the beginning of a line.

When a fill prefix is in effect, the fill commands remove the fill prefix from each line before filling and insert it on each line after filling. Auto Fill mode also inserts the fill prefix inserted on new lines it creates. Lines that do not start with the fill prefix are considered to start paragraphs, both in M-q and the paragraph commands; this is just right if you are using paragraphs with hanging indentation (every line indented except the first one). Lines which are blank or indented once the prefix is removed also separate or start paragraphs; this is what you want if you are writing multi-paragraph comments with a comment delimiter on each line.

The fill prefix is stored in the variable fill-prefix. Its value is a string, or nil when there is no fill prefix. This is a per-buffer variable; altering the variable affects only the current buffer, but there is a default value which you can change as well. See Locals.

Another way to use fill prefixes is through M-x fill-individual-paragraphs. This function divides the region into groups of consecutive lines with the same amount and kind of indentation and fills each group as a paragraph, using its indentation as a fill prefix.


Previous: , Up: Filling   [Contents][Index]