25.6.1 Auto Fill Mode
Auto Fill mode is a buffer-local minor mode (see Minor Modes) in which lines are broken automatically at spaces when the line becomes too wide.
M-x auto-fill-mode
​
Enable or disable Auto Fill mode.
SPC
​
RET
​
In Auto Fill mode, break lines when appropriate.
The mode command M-x auto-fill-mode
toggles Auto Fill mode in the current buffer. Like any other minor mode, with a positive numeric argument, it enables Auto Fill mode, and with a negative argument it disables it. To enable Auto Fill mode automatically in certain major modes, add auto-fill-mode
to the mode hooks (see Major Modes). When Auto Fill mode is enabled, the mode indicator ‘Fill
’ appears in the mode line (see Mode Line).
Auto Fill mode breaks lines automatically at spaces whenever they get longer than the desired width. This line breaking occurs only when you type SPC
or RET
. If you wish to insert a space or newline without permitting line-breaking, type C-q SPC
or C-q C-j
respectively. Also, C-o
inserts a newline without line breaking.
When Auto Fill mode breaks a line, it tries to obey the adaptive fill prefix: if a fill prefix can be deduced from the first and/or second line of the current paragraph, it is inserted into the new line (see Adaptive Fill). Otherwise the new line is indented, as though you had typed TAB
on it (see Indentation). In a programming language mode, if a line is broken in the middle of a comment, the comment is split by inserting new comment delimiters as appropriate.
Auto Fill mode does not refill entire paragraphs; it breaks lines but does not merge lines. Therefore, editing in the middle of a paragraph can result in a paragraph that is not correctly filled. To fill it, call the explicit fill commands (see Fill Commands).