Auto-increment
--------------
Number registers can also be auto-incremented and auto-decremented.
The increment or decrement value can be specified with a third argument
to the `nr' request or `\R' escape.
- Request: .nr ident value incr
Set number register IDENT to VALUE; the increment for
auto-incrementing is set to INCR. Note that the `\R' escape
doesn't support this notation.
To activate auto-incrementing, the escape `\n' has a special syntax
form.
- Escape: \n+I
- Escape: \n-I
- Escape: \n(+ID
- Escape: \n(-ID
- Escape: \n+(ID
- Escape: \n-(ID
- Escape: \n[+IDENT]
- Escape: \n[-IDENT]
- Escape: \n+[IDENT]
- Escape: \n-[IDENT]
Before interpolating, increment or decrement IDENT (one-character
name I, two-character name ID) by the auto-increment value as
specified with the `nr' request (or the `\R' escape). If no
auto-increment value has been specified, these syntax forms are
identical to `\n'.
For example,
.nr a 0 1
.nr xx 0 5
.nr foo 0 -2
\n+a, \n+a, \n+a, \n+a, \n+a
.br
\n-(xx, \n-(xx, \n-(xx, \n-(xx, \n-(xx
.br
\n+[foo], \n+[foo], \n+[foo], \n+[foo], \n+[foo]
produces
1, 2, 3, 4, 5
-5, -10, -15, -20, -25
-2, -4, -6, -8, -10
To change the increment value without changing the value of a
register (A in the example), the following can be used:
.nr a \na 10