Skip to main content

25.13 Nroff Mode

Nroff mode, a major mode derived from Text mode, is specialized for editing nroff files (e.g., Unix man pages). Type M-x nroff-mode to enter this mode. Entering Nroff mode runs the hook text-mode-hook, then nroff-mode-hook (see Hooks).

In Nroff mode, nroff command lines are treated as paragraph separators, pages are separated by β€˜.bp’ commands, and comments start with backslash-doublequote. It also defines these commands:

M-n​

Move to the beginning of the next line that isn’t an nroff command (nroff-forward-text-line). An argument is a repeat count.

M-p​

Like M-n but move up (nroff-backward-text-line).

M-?​

Displays in the echo area the number of text lines (lines that are not nroff commands) in the region (nroff-count-text-lines).

Electric Nroff mode is a buffer-local minor mode that can be used with Nroff mode. To toggle this minor mode, type M-x nroff-electric-mode (see Minor Modes). When the mode is on, each time you type RET to end a line containing an nroff command that opens a kind of grouping, the nroff command to close that grouping is automatically inserted on the following line.

If you use Outline minor mode with Nroff mode (see Outline Mode), heading lines are lines of the form β€˜.H’ followed by a number (the header level).