Sam (text editor)

Last updated
Sam
Sam text editor.png
A screenshot of Sam
Original author(s) Rob Pike
Developer(s) Bell Labs
Initial releaseearly 1980s
Written in C
Operating system Unix, Plan 9, Win32
Available inEnglish
Type Text editor
License 2021: MIT
2014: GPL-2.0-only
2002: LPL-1.02
Website sam.cat-v.org

Sam is a multi-file text editor based on structural regular expressions. It was originally designed in the early 1980s at Bell Labs by Rob Pike with the help of Ken Thompson and other Unix developers for the Blit windowing terminal running on Unix; it was later ported to other systems. Sam follows a classical modular Unix aesthetic. It is internally simple, its power leveraged by the composability of a small command language and extensibility through shell integration.

Contents

Design and features

Sam is designed as two synchronous programs: a command interpreter and a mouse-oriented bitmap windowing interface. The interpreter's command set is modeled after the UNIX editor ed and may be used to operate the editor from a standard text terminal. By default, however, Sam presents its own graphical user interface (GUI) window, samterm, which additionally allows point-and-click operations through pop-up context menus. This two-process structure allowed sam to access files on networked host systems through remote execution of the file-access process while running the windowing interface locally, thereby bypassing latency over slow connections.

Samterm presents windows to files being edited and to a persistent command window which accepts input as sam commands. Most common editing operations are quickly and naturally accomplished with the point-and-click interface, which also functions inside the command window. This latter fact allows commands to be edited (and resubmitted) just as any other text, a function inherited from the DMD 5620 terminal interface.

Command syntax

Sam's command syntax is formally similar to ed's or ex's, containing (structural-) regular expression based conditional and loop functions and scope addressing, even sharing some of ed's syntax for such functions. But while ed's commands are line-oriented, sam's are selection-oriented. Selections are contiguous strings of text (which may span multiple lines), and are specified either with the mouse (by sweeping it over a region of text) or by a pattern match. Sam's commands take such selections as basic—more or less as other Unix tools treat lines; thus, multi-line and sub-line patterns are as naturally handled by Sam as whole-line patterns are by ed, vi, AWK, Perl, etc. This is implemented through a model called structural regular expressions, which can 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 extends its basic text-editing command set to handling of multiple files, providing similar pattern-based conditional and loop commands for filename specification. Any sequence of text-editing commands may be applied as a unit to each such specification.

Infinite undos

Sam was one of the first text editors to support "infinite" undo to revert any number of editing errors. This feature, combined with Sam's facility to easily edit its own commands and, fundamentally, its small, orthogonal command set (containing only 33 commands), represent the program's bias toward a low learning threshold over other more expressive "power editors."

Endorsers

Sam is the preferred text editor of several eminent programmers. It was the first full screen editor Ken Thompson liked. [1] Sam is the text editor used by Bjarne Stroustrup, [2] Brian Kernighan, [3] [4] Douglas McIlroy and Tom Duff.[ citation needed ] Others, like Dennis Ritchie, Rob Pike and Russ Cox, have transitioned to acme, an editor with the same command language as sam, but with an assortment of additional features, including mouse chording and automatic tiling of opened files.

The latest version of sam was written as part of the Plan 9 operating system, but there are Microsoft Windows, macOS and X Window System [5] ports available.

See also

Notes

  1. Interview:Rob Pike Responds, Posted by Roblimo on Monday October 18, 2004, Slashdot
  2. Rzeszótko, Jarosław (2006-10-16). "Stiff asks, great programmers answer". Stifflog (Interview). Archived from the original on October 5, 2011. Retrieved 2008-11-01.
  3. Kernighan, Brian (July 2000). "An Interview with Brian Kernighan" (Interview). Interviewed by Budiu, Mihai. Retrieved 2008-11-01.
  4. Fridman, Lex (19 July 2020). Brian Kernighan's Programming Setup | Lex Fridman. YouTube. Event occurs at 44 seconds. Archived from the original on 2021-12-12. Retrieved 2020-10-03.
  5. https://github.com/deadpixi/sam

Related Research Articles

AWK Data-driven programming language made by Alfred Aho, Peter Weinberger and Brian Kernighan

AWK (awk) is a domain-specific language designed for text processing and typically used as a data extraction and reporting tool. Like sed and grep, it is a filter, and is a standard feature of most Unix-like operating systems.

Brian Kernighan Canadian computer scientist, one of the creators of Unix

Brian Wilson Kernighan is a Canadian computer scientist.

ed (text editor) Line-oriented text editor for Unix

ed is a line editor for Unix and Unix-like operating systems. It was one of the first parts of the Unix operating system that was developed, in August 1969. It remains part of the POSIX and Open Group standards for Unix-based operating systems, alongside the more sophisticated full-screen editor vi.

Plan 9 from Bell Labs Distributed operating system

Plan 9 from Bell Labs is a distributed operating system, originating in the Computing Science Research Center (CSRC) at Bell Labs in the mid-1980s, and building on UNIX concepts first developed there in the late 1960s. Since 2000, Plan 9 is free and open-source. The final official release was in early 2015.

QED is a line-oriented computer text editor that was developed by Butler Lampson and L. Peter Deutsch for the Berkeley Timesharing System running on the SDS 940. It was implemented by L. Peter Deutsch and Dana Angluin between 1965 and 1966.

sed is a Unix utility that parses and transforms text, using a simple, compact programming language. sed was developed from 1973 to 1974 by Lee E. McMahon of Bell Labs, and is available today for most operating systems. sed was based on the scripting features of the interactive editor ed and the earlier qed. sed was one of the earliest tools to support regular expressions, and remains in use for text processing, most notably with the substitution command. Popular alternative tools for plaintext string manipulation and "stream editing" include AWK and Perl.

Vim (text editor) Improved version of the Vi keyboard-oriented text editor

Vim is a free and open-source, screen-based text editor program. It is an improved clone of Bill Joy's vi. Vim's author, Bram Moolenaar, derived Vim from a port of the Stevie editor for Amiga and released a version to the public in 1991. Vim is designed for use both from a command-line interface and as a standalone application in a graphical user interface. Vim is released under the Vim license, which includes some charityware clauses that encourage users who enjoy the software to consider donating to children in Uganda. The Vim license is compatible with the GNU General Public License through a special clause allowing distribution of modified copies under the GNU GPL version 2.0 or later.

vi Keyboard-oriented text editor

vi is a screen-oriented text editor originally created for the Unix operating system. The portable subset of the behavior of vi and programs based on it, and the ex editor language supported within these programs, is described by the Single Unix Specification and POSIX.

grep is a command-line utility for searching plain-text data sets for lines that match a regular expression. Its name comes from the ed command g/re/p, which has the same effect. grep was originally developed for the Unix operating system, but later available for all Unix-like systems and some others such as OS-9.

Acme (text editor)

Acme is a text editor and graphical shell from the Plan 9 from Bell Labs operating system, designed and implemented by Rob Pike. It can use the Sam command language. The design of the interface was influenced by Oberon. It is different from other editing environments in that it acts as a 9P server. A distinctive element of the user interface is mouse chording.

In human–computer interaction and user interface design, cut, copy, and paste are related commands that offer an interprocess communication technique for transferring data through a computer's user interface. The cut command removes the selected data from its original position, while the copy command creates a duplicate; in both cases the selected data is kept in temporary storage. The data from the clipboard is later inserted wherever a paste command is issued. The data remains available to any application supporting the feature, thus allowing easy data transfer between applications.

Unix philosophy Philosophy on developing software

The Unix philosophy, originated by Ken Thompson, is a set of cultural norms and philosophical approaches to minimalist, modular software development. It is based on the experience of leading developers of the Unix operating system. Early Unix developers were important in bringing the concepts of modularity and reusability into software engineering practice, spawning a "software tools" movement. Over time, the leading developers of Unix established a set of cultural norms for developing software; these norms became as important and influential as the technology of Unix itself; this has been termed the "Unix philosophy."

In computer programming, glob patterns specify sets of filenames with wildcard characters. For example, the Unix Bash shell command mv *.txt textfiles/ moves all files with names ending in .txt from the current directory to the directory textfiles. Here, * is a wildcard standing for "any string of characters" and *.txt is a glob pattern. The other common wildcard is the question mark (?), which stands for one character. For example, mv ?.txt shorttextfiles/ will move all files named with a single character followed by .txt from the current directory to directory shorttextfiles, while ??.txt would match all files whose name consists of 2 characters followed by .txt.

This article provides basic comparisons for notable text editors. More feature details for text editors are available from the Category of text editor features and from the individual products' articles. This article may not be up-to-date or necessarily all-inclusive.

VEDIT

Vedit is a commercial text editor for 8080/Z-80-based systems, Microsoft Windows and MS-DOS from Greenview Data, Inc.

Unix Family of computer operating systems that derive from the original AT&T Unix

Unix is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and others.

Rob Pike Computer programmer and co-creator of Go

Robert "Rob" Pike is a Canadian programmer and author. He is best known for his work on the Go programming language and at Bell Labs, where he was a member of the Unix team and was involved in the creation of the Plan 9 from Bell Labs and Inferno operating systems, as well as the Limbo programming language.

Ken Thompson American computer scientist, creator of the Unix operating system

Kenneth Lane Thompson is an American pioneer of computer science. Thompson worked at Bell Labs for most of his career where he designed and implemented the original Unix operating system. He also invented the B programming language, the direct predecessor to the C programming language, and was one of the creators and early developers of the Plan 9 operating system. Since 2006, Thompson has worked at Google, where he co-developed the Go programming language.

Command-line interface Type of computer interface based on entering text commands and viewing text output

A command-line interface (CLI) processes commands to a computer program in the form of lines of text. The program which handles the interface is called a command-line interpreter or command-line processor. Operating systems implement a command-line interface in a shell for interactive access to operating system functions or services. Such access was primarily provided to users by computer terminals starting in the mid-1960s, and continued to be used throughout the 1970s and 1980s on VAX/VMS, Unix systems and personal computer systems including DOS, CP/M and Apple DOS.

The following outline is provided as an overview of and topical guide to the Perl programming language:

References