- Sam (text editor)
Infobox Software
name = Sam
caption =
collapsible =
author =Rob Pike
developer =Bell Labs
released = early 1980's
latest release version =
latest release date = July 4, 2003
latest preview version =
latest preview date =
frequently updated =
programming language = C
operating system =Unix ,Plan 9 , Win32
platform =
size =
language = English
status =
genre =Text editor
license =Lucent Public License
website = [http://swtch.com/plan9port/man/man1/sam.html Sam]Sam is a multi-file
text editor originally designed atBell Labs byRob Pike (with the help of Ken Thompson and other Unix developers) in the early 1980s for the Blit windowing terminal running onUnix , and later ported to other systems. It follows a classical modularUnix aesthetic; it is internally simple, its power leveraged by the composability of a small command language and extensibility through shell integration.Sam is designed as two synchronous programs: a command interpreter with a language modeled after the UNIX editor, ed, linked to a mouse-oriented bitmap windowing interface called "samterm". The command interpreter may be independently run in a text-only mode similarly to ed, from a
command line terminal; however, running samterm allows use of aGraphical User Interface with operation on text by point-and-click, withSmalltalk -80-style pop-up context menus for simple operations like cut and paste. Samterm provides, in addition to file windows, a persistent "command window" which accepts instructions from the command language; previous commands can be edited and resubmitted (a feature inherited from the DMD 5620 terminal interface). Most common editing operations are very quick and natural with the point-and-click interface. The two-process design also allows sam to access files on networked host systems through remote execution of the file-access process.While sam's syntax is formally similar to ed's, ed's commands are line-oriented; sam's are "selection"-oriented, where the selection may be "swept" out by
dragging the mouse cursor over a region of text, or by searching for a pattern match. Multi-line and sub-line patterns are as naturally handled by the command language as whole-line patterns are by ed's. This is enabled through a model called "structuralregular expressions ", which recursively apply regular-expression matching to obtain other (sub)selections within a given selection. In this way, sam's command set can be applied to substrings that are identified by arbitrarily complex context.Sam also allows editing commands to be applied simultaneously to multiple files, which are selected by pattern matching on their names. A sequence of commands may be applied as a unit to each selection. Sam was also one of the first text editors to support "infinite"
undo to revert any number of editing errors.Sam is the preferred text editor of many eminent computer scientists; it replaced ed as Ken Thompson's favorite text editor, and he still uses it to this day. Sam is the text editor used by
Bjarne Stroustrup [ [http://www.stifflog.com/2006/10/16/stiff-asks-great-programmers-answer/ Stifflog - Stiff asks, great programmers answer ] ] andBrian Kernighan [ [http://www.cs.cmu.edu/~mihaib/kernighan-interview/ An Interview with Brian Kernighan ] ] . Others, likeDennis Ritchie , have moved on to use acme instead. Sam vs. acme debates occur in the Plan 9 community (both are shipped with Plan 9) although both stem from a very similar aesthetic bias. (Both were written by Rob Pike.)The latest incarnation of sam was written as part of the Plan 9 operating system, but there are
Microsoft Windows andX Window System ports available.See also
* acme — Rob Pike's other popular text editor and successor of sam.
* ed — The original Unix text editor by Ken Thompson
*Plan 9 from Bell Labs
*List of Unix programs External links
*man|1|sam|Plan 9|screen editor with structural regular expressions
* [http://www.cs.bell-labs.com/sys/doc/sam/sam.pdf The text editor sam] Rob Pike's "The Text Editor Sam", from November 1987
* [http://doc.cat-v.org/bell_labs/structural_regexps/ Pike's essay on structural regular expressions]
* [http://plan9.bell-labs.com/sources/contrib/uriel/mirror/sam.tut.pdf Pike's tutorial for the sam command language]
* [http://plan9.bell-labs.com/netlib/research/sam.exe A Win32 version of sam]
* [http://plan9.bell-labs.com/plan9/addons.html Another Win32 version of sam (and other Plan 9 utilities)]
* [http://swtch.com/plan9port a new Unix version of sam]
* [http://plan9.bell-labs.com/sources/contrib/steve/doc/sam-refcard.pdf sam quick reference card]Citations
Wikimedia Foundation. 2010.