On Fri, Jul 2, 2021, at 4:03 PM, silas poulson wrote:
On 1 Jul 2021, at 18:48, Ethan Gardener <eekee57@fastmail.fm> wrote:
sam -d can't display line numbers

You can sort of display them via

,x {
=
p
}

Though it’s ugly and annoyingly can’t apply sam’s regex to remove the character locations.

My mail client swallowed the line with the equals sign until I tried to reply. If that's happening to anyone else, it's on a line on its own between the opening brace and the p.

It does work, but yeah, it's a bit on the ugly side. I can get line & char numbers onto the same lines as the text, but only on the ends of the lines which is even uglier. It's this:

,x/.*/ {
=
p
}

The regexp selects whole lines without the newlines. Reversing the order of = and p has no effect.

(This reminds me why I switched to Forth: I can program my editor properly instead of being constrained by a domain-specific language. But part of the problem was I couldn't get my head around Sam's C code. It probably didn't help that I started with terminal-editor communication; that was likely the deep end of the pool.)

In any case, Plan 9's ed has a nice "browse" command which sam can't match. I used to issue "0bn", then just "b" once per page. Or, if you don't want line numbers, leave out the "n".