683 lines · 13.6 KB · Text
RawDownload
.TH ED 1.SH NAMEed \- text editor.SH SYNOPSIS.B ed[.B -][.B -o][.I file].SH DESCRIPTION.I Edis a venerable text editor..PPIf a.I fileargument is given,.I edsimulates an.L ecommand (see below) on that file:it is read into.I ed'sbuffer so that it can be edited.The options are.TP.B -Suppress the printingof character counts by.LR e ,.LR r ,and.L wcommands and of the confirming .L !by.L !commands..TP.B -o(for output piping)Write all output to the standard error file except writing by.L wcommands.If no .I fileis given, make.B /fd/1the remembered file; see the.L ecommand below..PP.I Edoperates on a `buffer', a copy of the file it is editing;changes madein the buffer have no effect on the file until a.L w(write)command is given.The copy of the text being edited residesin a temporary file called the .IR buffer ..PPCommands to.I edhave a simple and regular structure: zero, one, ortwo.I addressesfollowed by a single character.IR command ,possiblyfollowed by parameters to the command.These addresses specify one or more lines in the buffer.Missing addresses are supplied by default..PPIn general, only one command may appear on a line.Certain commands allow the addition of text to the buffer.While.I edis accepting text, it is saidto be in.I  "input mode."In this mode, no commands are recognized;all input is merely collected.Input mode is left by typing a period .L .alone at thebeginning of a line..PP.I Edsupports the .I "regular expression"notation described in.IR regexp (6).Regular expressions are used in addresses to specifylines and in one command(see.I sbelow)to specify a portion of a line which is to be replaced.If it is desired to use one ofthe regular expression metacharacters as an ordinarycharacter, that character may be preceded by.RB ` \e '.This also applies to the character bounding the regularexpression (often .LR / )and to.L \eitself..PPTo understand addressing in.I edit is necessary to know that at any time there is a.I "current line."Generally, the current line isthe last line affected by a command; however,the exact effect on the current lineis discussed under the description ofeach command.Addresses are constructed as follows..TP1.The character.LR . ,customarily called `dot',addresses the current line..TP2.The character .L $addresses the last line of the buffer..TP3.A decimal number.I naddresses the.IR n -thline of the buffer..TP4..BI \'xaddresses the line marked with the name.IR x ,which must be a lower-case letter.Lines are marked with the.L kcommand..TP5.A regular expression enclosed in slashes (.LR / )addressesthe line found by searching forward from the current lineand stopping at the first line containing astring that matches the regular expression.If necessary the search wraps around to the beginning of thebuffer..TP6.A regular expression enclosed in queries .L ?addressesthe line found by searching backward from the current lineand stopping at the first line containinga string that matches the regular expression.If necessarythe search wraps around to the end of the buffer..TP7.An address followed by a plus sign .L +or a minus sign.L -followed by a decimal number specifies that address plus(resp. minus) the indicated number of lines.The plus sign may be omitted..TP8.An address followed by .L +(or.LR - )followed by aregular expression enclosed in slashes specifies the firstmatching line following (or preceding) that address.The search wraps around if necessary.The .L +may be omitted, so.L 0/x/addresses the.I firstline in the buffer with an .LR x .Enclosing the regular expression in .L ?reverses the search direction..TP9.If an address begins with .L +or.L -the addition or subtraction is taken with respect to the current line;e.g.\&.L -5is understood to mean.LR .-5 ..TP10.If an address ends with .L +or.LR - ,then 1 is added (resp. subtracted).As a consequence of this rule and rule 9,the address.L -refers to the line before the current line.Moreover,trailing.L +and.L -charactershave cumulative effect, so.L --refers to the currentline less 2..TP11.To maintain compatibility with earlier versions of the editor,the character .L ^in addresses is equivalent to.LR - ..PPCommands may require zero, one, or two addresses.Commands which require no addresses regard the presenceof an address as an error.Commands which accept one or two addressesassume default addresses when insufficient are given.If more addresses are given than a command requires,the last one or two (depending on what is accepted) are used..PPAddresses are separated from each other typically by a comma.LR , .They may also be separated by a semicolon.LR ; .In this case the current line is set tothe previous address before the next address is interpreted.If no address precedes a comma or semicolon, line 1 is assumed;if no address follows, the last line of the buffer is assumed.The second address of any two-address sequencemust correspond to a line following the line corresponding to the first address..PPIn the following list of.I edcommands, the default addressesare shown in parentheses.The parentheses are not part ofthe address, but are used to show that the given addresses arethe default.`Dot' means the current line..TP.RB (\|\fL.\fP\|) \|a.br.ns.TP<text>.br.ns.TP.B .Read the given textand append it after the addressed line.Dot is lefton the last line input, if therewere any, otherwise at the addressed line.Address .L 0is legal for this command; text is placedat the beginning of the buffer..TP.RB (\|\fL.,.\fP\|) \|b [ +- ][\fIpagesize\fP][ pln\fR]Browse.Print a `page', normally 20 lines.The optional .L +(default) or.L -specifies whether the next or previouspage is to be printed.The optional.I pagesizeis the number of lines in a page.The optional.LR p ,.LR n ,or .L lcauses printing in the specified format, initially.LR p .Pagesize and format are remembered between .L bcommands.Dot is left at the last line displayed..TP.RB (\|\fL.,.\fP\|) \|c.br.ns.TP<text>.br.ns.TP.B .Change.Delete the addressed lines, then accept inputtext to replace these lines.Dot is left at the last line input; if there were none,it is left at the line preceding the deleted lines..TP.RB (\|\fL.,.\fP\|) \|dDelete the addressed lines from the buffer.Dot is set to the line following the last line deleted, or tothe last line of the buffer if the deleted lines had no successor..TP.BI e " filename"Edit.Delete the entire contents of the buffer;then read the named file into the buffer.Dot is set to the last line of the buffer.The number of characters read is typed.The file name is remembered for possible use in later.LR e ,.LR r ,or.L wcommands.If.I filenameis missing, the remembered name is used..TP.BI E " filename"Unconditional.LR e ;see.RL ` q 'below..TP.BI f " filename"Print the currently remembered file name.If.I filenameis given,the currently remembered file name is first changed to.IR filename ..TP.RB (\|\fL1,$\fP\|) \|g/\fIregular\ expression\fP/\fIcommand\ list\fP.PD 0.TP.RB (\|\fL1,$\fP\|) \|g/\fIregular\ expression\fP/.TP.RB (\|\fL1,$\fP\|) \|g/\fIregular\ expression\fP.PDGlobal.First mark every line which matchesthe given.IR regular expression .Then for every such line, execute the.I command listwith dot initially set to that line.A single command or the first of multiple commandsappears on the same line with the global command.All lines of a multi-line list except the last line must end with.LR \e .The.RB \&` \&. \&'terminating input mode for an.LR a ,.LR i ,.L ccommand may be omitted if it would be on thelast line of the command list.The commands.L gand.L vare not permitted in the command list.Any character other than space or newline maybe used instead of .L /to delimit the regular expression.The second and third forms mean.BI g/ regular\ expression /p \f1..TP.RB (\| .\| ) \|i.PD 0.TP<text>.TP.B .Insert the given text before the addressed line.Dot is left at the last line input, or, if there were none,at the line before the addressed line.This command differs from the.I acommand only in the placement of thetext..PD.TP.RB (\| .,.+1 \|) \|jJoin the addressed lines into a single line;intermediate newlines are deleted.Dot is left at the resulting line..TP.RB (\|\fL.\fP\|) \|k\fIx\fPMark the addressed line with name.IR x ,which must be a lower-case letter.The address form.BI \' xthen addresses this line..ne 2.5.TP.RB (\|\fL.,.\fP\|) \|lList.Print the addressed lines in an unambiguous way:a tab is printed as.LR \et ,a backspace as.LR \eb ,backslashes as.LR \e\e ,and non-printing characters asa backslash, an.LR x ,and four hexadecimal digits.Long lines are folded,with the second and subsequent sub-lines indented one tab stop.If the last character in the line is a blank,it is followed by.LR \en .An.L lmay be appended, like.LR p ,to any non-I/O command..TP.RB (\|\fL.,.\fP\|) \|m\fIaMove.Reposition the addressed lines after the lineaddressed by.IR a .Dot is left at the last moved line..TP.RB (\|\fL.,.\fP\|) \|nNumber.Perform.LR p ,prefixing each line with its line number and a tab.An.L nmay be appended, like.LR p ,to any non-I/O command..TP.RB (\|\fL.,.\fP\|) \|pPrint the addressed lines.Dot is left at the last line printed.A.L pappended to any non-I/O command causes the then current lineto be printed after the command is executed..TP.RB (\|\fL.,.\fP\|) \|PThis command is a synonym for.LR p ..TP.B qQuit the editor.No automatic writeof a file is done.A.L qor.L ecommand is considered to be in error if the buffer hasbeen modified since the last.LR w ,.LR q ,

Lines 1–500 of 683.