In Sam, I tried variations of:

x g/foobar/m0

but consistently received "changes not in sequence" errors.

I don't understand.  As I read Mr. Pike's paper, Sam works much as ed in these
loops; one pass over the file to mark the changes to be made, another to make
the changes.

That's correct, as I understand it, but the changes have to proceed in
sequence from the beginning of the file to the end -- no jumping
around.  When you run x g/foobar/m0 you get a set of changes like
<insert a line at 0><delete a line someplace else><insert a line at
0><delete a line someplace else>.  Those changes jump back and forth
in the file, and sam won't allow it.

The only way I know to work around it is to use a temporary file.  Say
you're working on a file named foo and you have an empty file open
named tmp, then you can do this:

x g/foobar/m"tmp
X/tmp/,m"foo"0

Though I would probably just use the first command and work with the
lines in the temporary file.

It would be nice if sam converted 'x g/foobar/m0' to <insert all the
lines at 0><delete a line someplace else><delete a line someplace
else>, etc.  I don't know how hard that would be, though.

Micah

Reply via email to