while non-POSIX, the commonly-implemented z command displays a window of text (from the current+1 line and the following window-size, usually defaulting to $LINES) worth of text.
You can change the default window-size by specifying it after the z
z4
to show the next line and 4 more, and subsequent z commands will remember the 1+4-line window-size.
As usual, you can use the n and l suffixes to number lines and/or print them unambiguously:
5z3nl
will unambiguously print lines 5-8, including line-numbers.
You can use this to print the before/after lines of context:
g/pattern/-1z2n
will search for pattern and print/number the line before and after for additional context.
