Sam (text editor)

From Free net encyclopedia

Sam is a multi-file text editor originally designed at Bell Labs by Rob Pike (with the help of Ken Thompson and other Unix developers) in the early 1980s for the DMD 5620 windowing terminal running Unix. It follows a classical modular Unix aesthetic; it is internally simple, it's 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 the "samterm". The command interpreter may be independently run just as ed, from a command line terminal; running samterm allows operation on text by point-and-click, with Smalltalk-80-style pop-up context menus for simple operations like cut and paste. Instead of persistent window menus, samterm provides a persistent "command window" which accepts instructions from the command language.

While sam's syntax is formally similar to ed's, ed's commands are line-oriented; sam's are not. Standard regular expressions, as implemented originally in ed, take the single line of text as their basic unit: a file is an array of lines. Sam implements what Pike calls "structural regular expressions", which see the file as an array of characters---one continuous string. In this way, sam's command set can address sub-strings as arbitrarily limited as its mouse interface may select; multi- and inner-line patterns are as naturally handled by the command language as whole-line patterns are by ed's.

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. Others, like Dennis Ritchie have moved on to use acme instead. Sam vs. acme debates occur in the Plan 9 community 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 and X Window System ports available.

See also

External links