5.7 Comments

One of the most common forms of escape sequence is the comment.57

Escape sequence: \"

Start a comment; read everything up to the next newline in copy mode (see Copy Mode) and discard it. \" is interpreted even in copy mode.

It can be tricky to keep the comments from interfering with the appearance of the output. If the escape sequence is to the right of some text or a request, that portion of the line is ignored, but GNU troff processes spaces preceding it normally. This affects requests that read the remainder of the control line as a single argument, including ds, as, tm, and char; their variants; as well as ab, device, length, output, pi, pso, rd, sy, write, and writec.

One possibly irritating idiosyncrasy is that tabs should not be used to vertically align comments in the source document. Tab characters are not treated as separators between a request name and its first argument, nor between arguments.

A \" comment on a line by itself is treated as a blank line, because after eliminating the comment, that is all that remains.

apples bananas
\" cantaloupes
durians
    ⇒ apples bananas
    ⇒
    ⇒ durians

To compensate, it is common to combine the empty request with the comment escape sequence as ‘.\"’, causing the input line to be ignored.

Another commenting scheme sometimes seen is three consecutive neutral apostrophes (''') at the beginning of an input line. This works, but GNU troff emits a warning diagnostic (if enabled) about an undefined macro (namely ‘''’).

Escape sequence: \#

Start a whole-line comment; read everything up to and including the next newline in copy mode (see Copy Mode) and discard it. GNU troff introduced this extension to avoid the problems described above. \# is interpreted even in copy mode.

apples bananas
\# cantaloupes
durians
    ⇒ apples bananas durians
Request: .ig [end]

Ignore input until, in the current conditional block (if any),58 the macro end is called at the start of a control line, or the control line ‘..’ is encountered if end is not specified. ig is parsed as if it were a macro definition, but its contents are discarded, not stored.59

hand\c
.de TX
fasting
..
.ig TX
This is part of a large block of input that has been
temporarily(?) commented out.
We can restore it simply by removing the .ig request and
the call of its end macro.
.TX
    ⇒ handfasting