In the ex
editor, one can show line numbers by default by adding this line to a .exrc
file:
set number
Is there a way to have ed
start with line numbers showing by default, when lines are invoked?
No, there isn't. You have to remember to use the n
command in place of p
when looking at lines, or in place of .
when looking at the current line, or to add n
in places when the default is to print a line without line number (if allowed).
If you use the z
command to look at portions of the buffer at a time, e.g. 10 lines at a time from line 1 with 1z10
and then z
repeatedly to see the next 10 lines etc., then instead use 1z10n
and zn
to do the same thing with line numbers.
You can get the s///
command to print the result of a substitution with a line number using s///n
.
Use g/re/n
in place of g/re/p
to get numbering of the lines that matches the regular expression re
.
It all comes down to getting used to using n
when needed.