Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Sam (text editor)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{short description|Multi-file text editor}} {{multiple issues| {{more footnotes|date=September 2012}} {{more citations needed|date=September 2012}} }} {{Infobox software | name = Sam | logo = | screenshot = Sam text editor.png | caption = A screenshot of ''Sam'' | collapsible = | author = [[Rob Pike]] | developer = [[Bell Labs]] | released = early 1980s | latest release version = | latest release date = {{start date and age|2003|07|04}} | latest preview version = | latest preview date = | programming language = [[C (programming language)|C]] | operating system = [[Unix]], [[Plan 9 from Bell Labs|Plan 9]], [[Microsoft Windows|Win32]] | platform = | size = | language = English | genre = [[Text editor]] | license = 2021: [[MIT License|MIT]]<br />2014: [[GNU General Public License|GPL-2.0-only]]<br />2002: [[Lucent Public License|LPL-1.02]] | website = {{URL|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 (computer programmer)|Ken Thompson]] and other Unix developers for the [[Blit (computer terminal)|Blit]] windowing terminal running on [[Research Unix|v9 Unix]];<ref name="reader">{{cite tech report |first1=M. D. |last1=McIlroy |author-link1=Doug McIlroy |year=1987 |url=http://www.cs.dartmouth.edu/~doug/reader.pdf |title=A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986 |series=CSTR |number=139 |institution=Bell Labs}}</ref> it was later ported to other systems. Sam follows a classical [[modularity (programming)|modular]] [[Unix]] aesthetic. It is internally simple, its power leveraged by the composability of a small command language and [[extensibility]] through shell integration. ==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 (text 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 [[Blit (computer terminal)|DMD 5620]] terminal interface. ===Command syntax=== Sam's command syntax is formally similar to ed's or [[ex (text editor)|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 ''[[Drag and drop|sweeping]]'' it over a region of text) or by a [[pattern matching|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 (text editor)|ed]], [[Vi (text editor)|vi]], [[AWK]], [[Perl]], etc. This is implemented through a model called ''structural regular expressions'',<ref>{{cite journal |last=Pike |first=Rob |title=Structural Regular Expressions |url=http://doc.cat-v.org/bell_labs/structural_regexps/se.pdf |access-date=2008-11-01 |journal=EUUG Spring 1987}}</ref> 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 (computer programmer)|Ken Thompson]] liked.<ref>[https://interviews.slashdot.org/story/04/10/18/1153211/rob-pike-responds Interview:Rob Pike Responds], Posted by Roblimo on Monday October 18, 2004, Slashdot</ref> Sam is the text editor used by [[Bjarne Stroustrup]],<ref>{{cite interview |last=Rzeszótko |first=Jarosław |date=2006-10-16 |title=Stiff asks, great programmers answer |work=Stifflog |url=http://www.stifflog.com/2006/10/16/stiff-asks-great-programmers-answer |access-date=2008-11-01 |url-status=dead |archive-url=https://web.archive.org/web/20111005145715/http://www.stifflog.com/2006/10/16/stiff-asks-great-programmers-answer |archive-date=October 5, 2011}}</ref> [[Brian Kernighan]],<ref>{{cite interview |last=Kernighan |first=Brian |date=July 2000 |title=An Interview with Brian Kernighan |interviewer=Budiu, Mihai |url=https://www.cs.cmu.edu/~mihaib/kernighan-interview/ |accessdate=2008-11-01}}</ref><ref>{{Cite AV media|url=https://www.youtube.com/watch?v=EF2-vcp1Te0&feature=youtu.be&t=44 |archive-url=https://ghostarchive.org/varchive/youtube/20211212/EF2-vcp1Te0| archive-date=2021-12-12 |url-status=live|title=Brian Kernighan's Programming Setup {{!}} Lex Fridman|date=19 July 2020|last=Fridman|first=Lex|type=|language=|publisher=YouTube|time=44 seconds|access-date=2020-10-03}}{{cbignore}}</ref> [[Douglas McIlroy]] and [[Tom Duff]].{{citation needed|date=February 2020}} Others, like [[Dennis Ritchie]], [[Rob Pike]] and Russ Cox, have transitioned to [[acme (text editor)|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]]<ref>{{cite web | url=https://github.com/deadpixi/sam | title=Deadpixi/Sam | website=[[GitHub]] | date=17 May 2022 }}</ref> ports available. ==See also== {{Portal|Free and open-source software}} * [[acme (text editor)]] — Rob Pike's other popular text editor and successor of sam. * [[ed (text editor)]] — The original Unix text editor by [[Ken Thompson (computer programmer)|Ken Thompson]] * [[Plan 9 from Bell Labs]] * [[List of Unix commands]] ==Notes== {{Reflist}} ==References== *{{cite journal |first=Rob |last=Pike |date=October 1987 |title=The Text Editor sam |journal=Software: Practice and Experience |doi=10.1002/spe.4380171105 |volume=17 |issue=11 |pages=813–845 |s2cid=36076160 |url=http://doc.cat-v.org/plan_9/4th_edition/papers/sam/|access-date=2008-11-01|url-access=subscription }} *{{cite web |last=Pike |first=Rob |title=A tutorial for the sam command language |url=http://doc.cat-v.org/bell_labs/sam_lang_tutorial/ |access-date=2008-11-01}} ==External links== *[http://swtch.com/plan9port/man/man1/ssam.html ssam(1): stream interface to sam] *[http://sam.cat-v.org Sam Resources] *[http://man.cat-v.org/plan_9/1/sam sam(1): screen editor with structural regular expressions] *[http://swtch.com/plan9port A new Unix version of sam] as part of [[Plan 9 from User Space]] *[http://sam.cat-v.org/cheatsheet/ A sam quick reference card] {{Ken Thompson navbox}} {{Rob Pike navbox}} {{DEFAULTSORT:Sam (Text Editor)}} [[Category:Free text editors]] [[Category:Plan 9 from Bell Labs]] [[Category:Inferno (operating system)]] [[Category:Unix text editors]] [[Category:MacOS text editors]] [[Category:Windows text editors]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cbignore
(
edit
)
Template:Citation needed
(
edit
)
Template:Cite AV media
(
edit
)
Template:Cite interview
(
edit
)
Template:Cite journal
(
edit
)
Template:Cite tech report
(
edit
)
Template:Cite web
(
edit
)
Template:Infobox
(
edit
)
Template:Infobox software
(
edit
)
Template:Ken Thompson navbox
(
edit
)
Template:Main other
(
edit
)
Template:Multiple issues
(
edit
)
Template:Portal
(
edit
)
Template:Reflist
(
edit
)
Template:Rob Pike navbox
(
edit
)
Template:Short description
(
edit
)
Template:Template other
(
edit
)