.TH SAM 1.ds a \fR*\ \fP.SH NAMEsam, B, sam.save, samterm \- screen editor with structural regular expressions .SH SYNOPSIS.B sam[.I option ...] [.I files].PP.B sam.B -r.I machine.PP.B sam.save.PP.B B[.BI -nnnn].I file ....SH DESCRIPTION.I Samis a multi-file editor.It modifies a local copy of an external file.The copy is here called a.IR file .The files are listed in a menu available through mouse button 3or the.B ncommand.Each file has an associated name, usually the name of theexternal file from which it was read, and a `modified' bit that indicates whetherthe editor's file agrees with the external file.The external file is not read intothe editor's file until it first becomes the current file\(emthat towhich editing commands apply\(emwhereupon its menu entry is printed.The options are.TF -rmachine.TP.B -aAutoindent. In this mode, when a newline character is typedin the terminal interface,.I samtermcopies leading white space on the current line to the new line..TP.B -dDo not `download' the terminal part of.IR sam .Editing will be done with the command language only, as in.IR ed (1)..TP.BI -r " machineRun the host part remotelyon the specified machine, the terminal part locally..TP.BI -s " pathStart the host part from the specified file on the remote host.Only meaningful with the.BI -roption..TP.BI -t " pathStart the terminal part from the specified file. Usefulfor debugging..PD.SS Regular expressionsRegular expressions are as in.IR regexp (6)with the addition of.BR \ento represent newlines.A regular expression may never contain a literal newline character.The emptyregular expression stands for the last complete expression encountered.A regular expression in.I sammatches the longest leftmost substring formallymatched by the expression.Searching in the reverse direction is equivalentto searching backwards with the catenation operations reversed inthe expression..SS AddressesAn address identifies a substring in a file.In the following, `character.IR n 'means the null stringafter the.IR n -thcharacter in the file, with 1 thefirst character in the file.`Line.IR n 'means the.IR n -thmatch,starting at the beginning of the file, of the regular expression.LR .*\en? .All files always have a current substring, called dot,that is the default address..SS Simple Addresses.PD 0.TP.BI # nThe empty string after character.IR n ;.B #0is the beginning of the file..TP.I nLine.IR n ;.B 0is the beginning of the file..TP.BI / regexp /.PD 0.TP.BI ? regexp ?The substring that matches the regular expression,found by looking toward the end .RB ( / )or beginning.RB ( ? )of the file,and if necessary continuing the search from the other end to thestarting point of the search.The matched substring may straddlethe starting point.When entering a pattern containing a literal question markfor a backward search, the question mark should bespecified as a member of a class..PD.TP.B 0The string before the first full line.This is not necessarilythe null string; see.B +and.B -below..TP.B $The null string at the end of the file..TP.B .Dot..TP.B \&'The mark in the file (see the.B kcommand below)..TP\fB"\f2regexp\fB"\f1\f1Preceding a simple address (default.BR . ),refers to the address evaluated in the unique file whose menu linematches the regular expression..PD.SS Compound AddressesIn the following,.I a1and.I a2are addresses..TF a1+a2.TP.IB a1 + a2The address.I a2evaluated starting at the end of.IR a1 ..TP.IB a1 - a2The address.I a2evaluated looking in the reverse directionstarting at the beginning of.IR a1 ..TP.IB a1 , a2The substring from the beginning of.I a1to the end of.IR a2 .If.I a1is missing,.B 0is substituted.If.I a2is missing,.B $is substituted..TP.IB a1 ; a2Like.IB a1 , a2\f1,but with.I a2evaluated at the end of, and dot set to,.IR a1 ..PD.PPThe operators.B +and.B -are high precedence, while.B ,and.B ;are low precedence..PPIn both.B +and.B -forms, if.I a2is a line or character address with a missingnumber, the number defaults to 1.If.I a1is missing,.L .is substituted.If both.I a1and.I a2are present and distinguishable,.B +may be elided..I a2may be a regularexpression; if it is delimited by.LR ? 's,the effect of the.B +or.B -is reversed..PPIt is an error for a compound address to represent a malformed substring.Some useful idioms: .IB a1 +-\%(\f2a1\fB-+\f1)selects the line containingthe end (beginning) of a1..BI 0/ regexp /locates the first match of the expression in the file.(The form.B 0;//sets dot unnecessarily.).BI ./ regexp /// finds the second following occurrence of the expression,and.BI .,/ regexp /extends dot..SS CommandsIn the following, text demarcated by slashes represents text delimitedby any printablecharacter except alphanumerics.Any number oftrailing delimiters may be elided, with multiple elisions then representingnull strings, but the first delimiter must alwaysbe present.In any delimited text,newline may not appear literally;.B \enmay be typed for newline; and.B \e/quotes the delimiter, here .LR / .Backslash is otherwise interpreted literally, except in.B scommands..PPMost commands may be prefixed by an address to indicate their rangeof operation.Those that may not are marked with a .L *below.If a command takesan address and none is supplied, dot is used.The sole exception isthe.B wcommand, which defaults to.BR 0,$ .In the description, `range' is usedto represent whatever address is supplied.Many commands set thevalue of dot as a side effect.If so, it is always set to the `result'of the change: the empty string for a deletion, the new text for aninsertion, etc. (but see the.B sand.B ecommands)..br.ne 1.2i.SS Text commands.PD 0.TP.BI a/ text /.TPor.TP.B a.TP.I lines of text.TP.B .Insert the text into the file after the range.Set dot..PD.TP.B c\fP.br.ns.TP.B i\fPSame as.BR a ,but.B creplaces the text, while.B iinserts.I beforethe range..TP.B dDelete the text in the range.Set dot..TP.BI s/ regexp / text /Substitute.I textfor the first match to the regular expression in the range.Set dot to the modified range.In .I textthe character.B &stands for the stringthat matched the expression. Backslash behaves as usual unless followed bya digit:.BI \e dstands for the string that matched thesubexpression begun by the.IR d -thleft parenthesis.If.I sis followed immediately by anumber.IR n ,as in.BR s2/x/y/ ,the.IR n -thmatch in the range is substituted.If thecommand is followed by a.BR g ,as in.BR s/x/y/g ,all matches in the rangeare substituted..TP.BI m " a1.br.ns.TP.BI t " a1Move.RB ( m )or copy.RB ( t )the range to after.IR a1 .Set dot..SS Display commands.PD 0.TP.B pPrint the text in the range.Set dot..TP.B =Print the line address and character address of the range..TP.B =#Print just the character address of the range..PD.SS File commands.PD 0.TP.BI \*ab " file-listSet the current file to the first file named in the listthat.I samalso has in its menu.The list may be expressed.BI < "Plan 9 command"in which case the file names are taken as words (in the shell sense)generated by the Plan 9 command..TP.BI \*aB " file-listSame as.BR b ,except that file names not in the menu are entered there,and all file names in the list are examined..TP.B \*anPrint a menu of files.The format is:.RS.TP 11.BR ' " or blankindicating the file is modified or clean,.TP 11.BR - " or \&" +indicating the file is unread or has been read(in the terminal,.B *means more than one window is open),.TP 11.BR . " or blankindicating the current file,.TP 11a blank,.TP 11and the file name..RE.TP 0.BI \*aD " file-listDelete the named files from the menu.If no files are named, the current file is deleted.It is an error to.B Da modified file, but a subsequent.B Dwill delete such a file..PD.SS I/O Commands.PD 0.TP.BI \*ae " filenameReplace the file by the contents of the named external file.Set dot to the beginning of the file..TP.BI r " filenameReplace the text in the range by the contents of the named external file.Set dot..TP.BI w " filenameWrite the range (default.BR 0,$ )to the named external file..TP.BI \*af " filenameSet the file name and print the resulting menu entry..PPIf the file name is absent from any of these, the current file name is used..B ealways sets the file name;.B rand.B wdo so if the file has no name..TP.BI < " Plan 9-commandReplace the range by the standard output of thePlan 9 command..TP.BI > " Plan 9-commandSend the range to the standard input of thePlan 9 command..TP.BI | " Plan 9-commandSend the range to the standard input, and replace it bythe standard output, of thePlan 9 command..TP.BI \*a! " Plan 9-commandRun thePlan 9 command..TP.BI \*acd " directoryChange working directory.Lines 1–500 of 891. Load more
.TH SAM 1 .ds a \fR*\ \fP .SH NAME sam, B, sam.save, samterm \- screen editor with structural regular expressions .SH SYNOPSIS .B sam [ .I option ... ] [ .I files ] .PP .B sam .B -r .I machine .PP .B sam.save .PP .B B [ .BI -nnnn ] .I file ... .SH DESCRIPTION .I Sam is a multi-file editor. It modifies a local copy of an external file. The copy is here called a .IR file . The files are listed in a menu available through mouse button 3 or the .B n command. Each file has an associated name, usually the name of the external file from which it was read, and a `modified' bit that indicates whether the editor's file agrees with the external file. The external file is not read into the editor's file until it first becomes the current file\(emthat to which editing commands apply\(emwhereupon its menu entry is printed. The options are .TF -rmachine .TP .B -a Autoindent. In this mode, when a newline character is typed in the terminal interface, .I samterm copies leading white space on the current line to the new line. .TP .B -d Do not `download' the terminal part of .IR sam . Editing will be done with the command language only, as in .IR ed (1). .TP .BI -r " machine Run the host part remotely on the specified machine, the terminal part locally. .TP .BI -s " path Start the host part from the specified file on the remote host. Only meaningful with the .BI -r option. .TP .BI -t " path Start the terminal part from the specified file. Useful for debugging. .PD .SS Regular expressions Regular expressions are as in .IR regexp (6) with the addition of .BR \en to represent newlines. A regular expression may never contain a literal newline character. The empty regular expression stands for the last complete expression encountered. A regular expression in .I sam matches the longest leftmost substring formally matched by the expression. Searching in the reverse direction is equivalent to searching backwards with the catenation operations reversed in the expression. .SS Addresses An address identifies a substring in a file. In the following, `character .IR n ' means the null string after the .IR n -th character in the file, with 1 the first character in the file. `Line .IR n ' means the .IR n -th match, starting at the beginning of the file, of the regular expression .LR .*\en? . All files always have a current substring, called dot, that is the default address. .SS Simple Addresses .PD 0 .TP .BI # n The empty string after character .IR n ; .B #0 is the beginning of the file. .TP .I n Line .IR n ; .B 0 is the beginning of the file. .TP .BI / regexp / .PD 0 .TP .BI ? regexp ? The substring that matches the regular expression, found by looking toward the end .RB ( / ) or beginning .RB ( ? ) of the file, and if necessary continuing the search from the other end to the starting point of the search. The matched substring may straddle the starting point. When entering a pattern containing a literal question mark for a backward search, the question mark should be specified as a member of a class. .PD .TP .B 0 The string before the first full line. This is not necessarily the null string; see .B + and .B - below. .TP .B $ The null string at the end of the file. .TP .B . Dot. .TP .B \&' The mark in the file (see the .B k command below). .TP \fB"\f2regexp\fB"\f1\f1 Preceding a simple address (default .BR . ), refers to the address evaluated in the unique file whose menu line matches the regular expression. .PD .SS Compound Addresses In the following, .I a1 and .I a2 are addresses. .TF a1+a2 .TP .IB a1 + a2 The address .I a2 evaluated starting at the end of .IR a1 . .TP .IB a1 - a2 The address .I a2 evaluated looking in the reverse direction starting at the beginning of .IR a1 . .TP .IB a1 , a2 The substring from the beginning of .I a1 to the end of .IR a2 . If .I a1 is missing, .B 0 is substituted. If .I a2 is missing, .B $ is substituted. .TP .IB a1 ; a2 Like .IB a1 , a2\f1, but with .I a2 evaluated at the end of, and dot set to, .IR a1 . .PD .PP The operators .B + and .B - are high precedence, while .B , and .B ; are low precedence. .PP In both .B + and .B - forms, if .I a2 is a line or character address with a missing number, the number defaults to 1. If .I a1 is missing, .L . is substituted. If both .I a1 and .I a2 are present and distinguishable, .B + may be elided. .I a2 may be a regular expression; if it is delimited by .LR ? 's, the effect of the .B + or .B - is reversed. .PP It is an error for a compound address to represent a malformed substring. Some useful idioms: .IB a1 +- \%(\f2a1\fB-+\f1) selects the line containing the end (beginning) of a1. .BI 0/ regexp / locates the first match of the expression in the file. (The form .B 0;// sets dot unnecessarily.) .BI ./ regexp /// finds the second following occurrence of the expression, and .BI .,/ regexp / extends dot. .SS Commands In the following, text demarcated by slashes represents text delimited by any printable character except alphanumerics. Any number of trailing delimiters may be elided, with multiple elisions then representing null strings, but the first delimiter must always be present. In any delimited text, newline may not appear literally; .B \en may be typed for newline; and .B \e/ quotes the delimiter, here .LR / . Backslash is otherwise interpreted literally, except in .B s commands. .PP Most commands may be prefixed by an address to indicate their range of operation. Those that may not are marked with a .L * below. If a command takes an address and none is supplied, dot is used. The sole exception is the .B w command, which defaults to .BR 0,$ . In the description, `range' is used to represent whatever address is supplied. Many commands set the value of dot as a side effect. If so, it is always set to the `result' of the change: the empty string for a deletion, the new text for an insertion, etc. (but see the .B s and .B e commands). .br .ne 1.2i .SS Text commands .PD 0 .TP .BI a/ text / .TP or .TP .B a .TP .I lines of text .TP .B . Insert the text into the file after the range. Set dot. .PD .TP .B c\fP .br .ns .TP .B i\fP Same as .BR a , but .B c replaces the text, while .B i inserts .I before the range. .TP .B d Delete the text in the range. Set dot. .TP .BI s/ regexp / text / Substitute .I text for the first match to the regular expression in the range. Set dot to the modified range. In .I text the character .B & stands for the string that matched the expression. Backslash behaves as usual unless followed by a digit: .BI \e d stands for the string that matched the subexpression begun by the .IR d -th left parenthesis. If .I s is followed immediately by a number .IR n , as in .BR s2/x/y/ , the .IR n -th match in the range is substituted. If the command is followed by a .BR g , as in .BR s/x/y/g , all matches in the range are substituted. .TP .BI m " a1 .br .ns .TP .BI t " a1 Move .RB ( m ) or copy .RB ( t ) the range to after .IR a1 . Set dot. .SS Display commands .PD 0 .TP .B p Print the text in the range. Set dot. .TP .B = Print the line address and character address of the range. .TP .B =# Print just the character address of the range. .PD .SS File commands .PD 0 .TP .BI \*ab " file-list Set the current file to the first file named in the list that .I sam also has in its menu. The list may be expressed .BI < "Plan 9 command" in which case the file names are taken as words (in the shell sense) generated by the Plan 9 command. .TP .BI \*aB " file-list Same as .BR b , except that file names not in the menu are entered there, and all file names in the list are examined. .TP .B \*an Print a menu of files. The format is: .RS .TP 11 .BR ' " or blank indicating the file is modified or clean, .TP 11 .BR - " or \&" + indicating the file is unread or has been read (in the terminal, .B * means more than one window is open), .TP 11 .BR . " or blank indicating the current file, .TP 11 a blank, .TP 11 and the file name. .RE .TP 0 .BI \*aD " file-list Delete the named files from the menu. If no files are named, the current file is deleted. It is an error to .B D a modified file, but a subsequent .B D will delete such a file. .PD .SS I/O Commands .PD 0 .TP .BI \*ae " filename Replace the file by the contents of the named external file. Set dot to the beginning of the file. .TP .BI r " filename Replace the text in the range by the contents of the named external file. Set dot. .TP .BI w " filename Write the range (default .BR 0,$ ) to the named external file. .TP .BI \*af " filename Set the file name and print the resulting menu entry. .PP If the file name is absent from any of these, the current file name is used. .B e always sets the file name; .B r and .B w do so if the file has no name. .TP .BI < " Plan 9-command Replace the range by the standard output of the Plan 9 command. .TP .BI > " Plan 9-command Send the range to the standard input of the Plan 9 command. .TP .BI | " Plan 9-command Send the range to the standard input, and replace it by the standard output, of the Plan 9 command. .TP .BI \*a! " Plan 9-command Run the Plan 9 command. .TP .BI \*acd " directory Change working directory.