26.3 Paragraphs

The Emacs commands for manipulating paragraphs are also on Meta keys.

M-{

Move back to previous paragraph beginning (backward-paragraph).

M-}

Move forward to next paragraph end (forward-paragraph).

M-h

Put point and mark around this or next paragraph (mark-paragraph).

M-{ (backward-paragraph) moves to the beginning of the current or previous paragraph, depending on where point is when the command is invoked (see below for the definition of a paragraph). M-} (forward-paragraph) similarly moves to the end of the current or next paragraph. If there is a blank line before the paragraph, M-{ moves to the blank line.

When you wish to operate on a paragraph, type M-h (mark-paragraph) to set the region around it. For example, M-h C-w kills the paragraph around or after point. M-h puts point at the beginning and mark at the end of the paragraph point was in. If point is between paragraphs (in a run of blank lines, or at a boundary), M-h sets the region around the paragraph following point. If there are blank lines preceding the first line of the paragraph, one of these blank lines is included in the region. If the region is already active, the command sets the mark without changing point, and each subsequent M-h further advances the mark by one paragraph.

The definition of a paragraph depends on the major mode. In Fundamental mode, as well as Text mode and related modes, a paragraph is separated from neighboring paragraphs by one or more blank lines—lines that are either empty, or consist solely of space, tab and/or formfeed characters. In programming language modes, paragraphs are usually defined in a similar way, so that you can use the paragraph commands even though there are no paragraphs as such in a program.

Note that an indented line is not itself a paragraph break in Text mode. If you want indented lines to separate paragraphs, use Paragraph-Indent Text mode instead. See Text Mode.

If you set a fill prefix, then paragraphs are delimited by all lines which don’t start with the fill prefix. See Filling Text.

The precise definition of a paragraph boundary is controlled by the variables paragraph-separate and paragraph-start. The value of paragraph-start is a regular expression that should match lines that either start or separate paragraphs (see Syntax of Regular Expressions). The value of paragraph-separate is another regular expression that should match lines that separate paragraphs without being part of any paragraph (for example, blank lines). Lines that start a new paragraph and are contained in it must match only paragraph-start, not paragraph-separate. For example, in Fundamental mode, paragraph-start is "\f\\|[ \t]*$", and paragraph-separate is "[ \t\f]*$".

Note that paragraph-start and paragraph-separate are matched against the text at the left margin, which is not necessarily the beginning of the line, so these regexps should not use ‘^’ as an anchor, to ensure that the paragraph functions will work equally within a region of text indented by a margin setting.