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

25.5.1 Auto Fill Mode

Auto Fill mode is a buffer-local minor mode (see Minor Modes) in which lines are broken automatically when they become too wide. Breaking happens only when you type a SPC or RET.

M-x auto-fill-mode

Enable or disable Auto Fill mode.


In Auto Fill mode, break lines when appropriate.

The mode command M-x auto-fill-mode toggles Auto Fill mode in the current buffer. With a positive numeric argument, it enables Auto Fill mode, and with a negative argument it disables it. If auto-fill-mode is called from Lisp with an omitted or nil argument, it enables Auto Fill mode. 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).

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