Fill current paragraph (
Set the fill column (
Fill each paragraph in the region (
Fill the region, considering it as one paragraph.
Center a line.
The command M-q (
fill-paragraph) fills the
current paragraph. It redistributes the line breaks within the
paragraph, and deletes any excess space and tab characters occurring
within the paragraph, in such a way that the lines end up fitting
within a certain maximum width.
Normally, M-q acts on the paragraph where point is, but if point is between paragraphs, it acts on the paragraph after point. If the region is active, it acts instead on the text in the region. You can also call M-x fill-region to specifically fill the text in the region.
fill-region use the usual Emacs criteria for
finding paragraph boundaries (see Paragraphs). For more control,
you can use M-x fill-region-as-paragraph, which refills
everything between point and mark as a single paragraph. This command
deletes any blank lines within the region, so separate blocks of text
end up combined into one block.
A numeric argument to M-q tells it to justify the text
as well as filling it. This means that extra spaces are inserted to
make the right margin line up exactly at the fill column. To remove
the extra spaces, use M-q with no argument. (Likewise for
The maximum line width for filling is specified by the buffer-local
fill-column. The default value (see Locals) is
70. The easiest way to set
fill-column in the current buffer
is to use the command C-x f (
set-fill-column). With a
numeric argument, it uses that as the new fill column. With just
C-u as argument, it sets
fill-column to the current
horizontal position of point.
The command M-o M-s (
center-line) centers the current line
within the current fill column. With an argument n, it centers
n lines individually and moves past them. This binding is
made by Text mode and is available only in that and related modes
(see Text Mode).
By default, Emacs considers a period followed by two spaces or by a
newline as the end of a sentence; a period followed by just one space
indicates an abbreviation, not the end of a sentence. Accordingly,
the fill commands will not break a line after a period followed by
just one space. If you set the variable
nil, the fill commands will
break a line after a period followed by one space, and put just one
space after each period. See Sentences, for other effects and
possible drawbacks of this.
If the variable
colon-double-space is non-
fill commands put two spaces after a colon.
To specify additional conditions where line-breaking is not allowed,
customize the abnormal hook variable
(see Hooks). Each function in this hook is called with no
arguments, with point positioned where Emacs is considering breaking a
line. If a function returns a non-
nil value, Emacs will not
break the line there. Functions you can use there include:
fill-single-word-nobreak-p (don’t break after the first word of
a sentence or before the last);
(don’t break after a one-letter word); and
(don’t break after ‘(’ or before ‘)’, ‘:’ or ‘?’).