<s>
Sam	B-Application
is	O
a	O
multi-file	O
text	B-Application
editor	I-Application
based	O
on	O
structural	O
regular	B-Language
expressions	I-Language
.	O
</s>
<s>
It	O
was	O
originally	O
designed	O
in	O
the	O
early	O
1980s	O
at	O
Bell	O
Labs	O
by	O
Rob	O
Pike	O
with	O
the	O
help	O
of	O
Ken	O
Thompson	O
and	O
other	O
Unix	B-Application
developers	O
for	O
the	O
Blit	B-Protocol
windowing	O
terminal	O
running	O
on	O
Unix	B-Application
;	O
it	O
was	O
later	O
ported	O
to	O
other	O
systems	O
.	O
</s>
<s>
Sam	B-Application
follows	O
a	O
classical	O
modular	B-Architecture
Unix	B-Application
aesthetic	O
.	O
</s>
<s>
It	O
is	O
internally	O
simple	O
,	O
its	O
power	O
leveraged	O
by	O
the	O
composability	O
of	O
a	O
small	O
command	O
language	O
and	O
extensibility	B-Architecture
through	O
shell	O
integration	O
.	O
</s>
<s>
Sam	B-Application
is	O
designed	O
as	O
two	O
synchronous	O
programs	O
:	O
a	O
command	O
interpreter	O
and	O
a	O
mouse-oriented	O
bitmap	O
windowing	O
interface	O
.	O
</s>
<s>
The	O
interpreter	O
's	O
command	O
set	O
is	O
modeled	O
after	O
the	O
UNIX	B-Application
editor	O
ed	B-Application
and	O
may	O
be	O
used	O
to	O
operate	O
the	O
editor	O
from	O
a	O
standard	O
text	O
terminal	O
.	O
</s>
<s>
By	O
default	O
,	O
however	O
,	O
Sam	B-Application
presents	O
its	O
own	O
graphical	B-Application
user	I-Application
interface	I-Application
(	O
GUI	B-Application
)	O
window	O
,	O
samterm	O
,	O
which	O
additionally	O
allows	O
point-and-click	O
operations	O
through	O
pop-up	O
context	O
menus	O
.	O
</s>
<s>
This	O
two-process	O
structure	O
allowed	O
sam	B-Application
to	O
access	O
files	O
on	O
networked	O
host	O
systems	O
through	O
remote	O
execution	O
of	O
the	O
file-access	O
process	O
while	O
running	O
the	O
windowing	O
interface	O
locally	O
,	O
thereby	O
bypassing	O
latency	O
over	O
slow	O
connections	O
.	O
</s>
<s>
Samterm	O
presents	O
windows	O
to	O
files	O
being	O
edited	O
and	O
to	O
a	O
persistent	O
command	O
window	O
which	O
accepts	O
input	O
as	O
sam	B-Application
commands	O
.	O
</s>
<s>
This	O
latter	O
fact	O
allows	O
commands	O
to	O
be	O
edited	O
(	O
and	O
resubmitted	O
)	O
just	O
as	O
any	O
other	O
text	O
,	O
a	O
function	O
inherited	O
from	O
the	O
DMD	B-Protocol
5620	I-Protocol
terminal	O
interface	O
.	O
</s>
<s>
Sam	B-Application
's	O
command	O
syntax	O
is	O
formally	O
similar	O
to	O
ed	B-Application
's	O
or	O
ex	B-Device
's	I-Device
,	O
containing	O
(	O
structural	O
-	O
)	O
regular	B-Language
expression	I-Language
based	O
conditional	O
and	O
loop	O
functions	O
and	O
scope	O
addressing	O
,	O
even	O
sharing	O
some	O
of	O
ed	B-Application
's	O
syntax	O
for	O
such	O
functions	O
.	O
</s>
<s>
But	O
while	O
ed	B-Application
's	O
commands	O
are	O
line-oriented	O
,	O
sam	B-Application
's	O
are	O
selection-oriented	O
.	O
</s>
<s>
Selections	O
are	O
contiguous	O
strings	O
of	O
text	O
(	O
which	O
may	O
span	O
multiple	O
lines	O
)	O
,	O
and	O
are	O
specified	O
either	O
with	O
the	O
mouse	O
(	O
by	O
sweeping	O
it	O
over	O
a	O
region	O
of	O
text	O
)	O
or	O
by	O
a	O
pattern	B-Language
match	I-Language
.	O
</s>
<s>
Sam	B-Application
's	O
commands	O
take	O
such	O
selections	O
as	O
basic	O
—	O
more	O
or	O
less	O
as	O
other	O
Unix	B-Application
tools	I-Application
treat	O
lines	O
;	O
thus	O
,	O
multi-line	O
and	O
sub-line	O
patterns	O
are	O
as	O
naturally	O
handled	O
by	O
Sam	B-Application
as	O
whole-line	O
patterns	O
are	O
by	O
ed	B-Application
,	O
vi	B-Application
,	O
AWK	B-Application
,	O
Perl	B-Language
,	O
etc	O
.	O
</s>
<s>
This	O
is	O
implemented	O
through	O
a	O
model	O
called	O
structural	O
regular	B-Language
expressions	I-Language
,	O
which	O
can	O
recursively	O
apply	O
regular-expression	O
matching	O
to	O
obtain	O
other	O
(	O
sub	O
)	O
selections	O
within	O
a	O
given	O
selection	O
.	O
</s>
<s>
In	O
this	O
way	O
,	O
sam	B-Application
's	O
command	O
set	O
can	O
be	O
applied	O
to	O
substrings	O
that	O
are	O
identified	O
by	O
arbitrarily	O
complex	O
context	O
.	O
</s>
<s>
Sam	B-Application
extends	O
its	O
basic	O
text-editing	O
command	O
set	O
to	O
handling	O
of	O
multiple	O
files	O
,	O
providing	O
similar	O
pattern-based	O
conditional	O
and	O
loop	O
commands	O
for	O
filename	O
specification	O
.	O
</s>
<s>
Sam	B-Application
was	O
one	O
of	O
the	O
first	O
text	B-Application
editors	I-Application
to	O
support	O
"	O
infinite	O
"	O
undo	B-Application
to	O
revert	O
any	O
number	O
of	O
editing	O
errors	O
.	O
</s>
<s>
This	O
feature	O
,	O
combined	O
with	O
Sam	B-Application
's	O
facility	O
to	O
easily	O
edit	O
its	O
own	O
commands	O
and	O
,	O
fundamentally	O
,	O
its	O
small	O
,	O
orthogonal	O
command	O
set	O
(	O
containing	O
only	O
33	O
commands	O
)	O
,	O
represent	O
the	O
program	O
's	O
bias	O
toward	O
a	O
low	O
learning	O
threshold	O
over	O
other	O
more	O
expressive	O
"	O
power	O
editors.	O
"	O
</s>
<s>
Sam	B-Application
is	O
the	O
preferred	O
text	B-Application
editor	I-Application
of	O
several	O
eminent	O
programmers	O
.	O
</s>
<s>
Sam	B-Application
is	O
the	O
text	B-Application
editor	I-Application
used	O
by	O
Bjarne	O
Stroustrup	O
,	O
Brian	O
Kernighan	O
,	O
Douglas	O
McIlroy	O
and	O
Tom	O
Duff	O
.	O
</s>
<s>
Others	O
,	O
like	O
Dennis	O
Ritchie	O
,	O
Rob	O
Pike	O
and	O
Russ	O
Cox	O
,	O
have	O
transitioned	O
to	O
acme	B-Application
,	O
an	O
editor	O
with	O
the	O
same	O
command	O
language	O
as	O
sam	B-Application
,	O
but	O
with	O
an	O
assortment	O
of	O
additional	O
features	O
,	O
including	O
mouse	O
chording	O
and	O
automatic	O
tiling	O
of	O
opened	O
files	O
.	O
</s>
<s>
The	O
latest	O
version	O
of	O
sam	B-Application
was	O
written	O
as	O
part	O
of	O
the	O
Plan	B-Operating_System
9	I-Operating_System
operating	O
system	O
,	O
but	O
there	O
are	O
Microsoft	B-Application
Windows	I-Application
,	O
macOS	B-Application
and	O
X	B-Operating_System
Window	I-Operating_System
System	I-Operating_System
ports	O
available	O
.	O
</s>
