⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ed.1

📁 早期freebsd实现
💻 1
📖 第 1 页 / 共 2 页
字号:
.\" Copyright (c) 1992, 1993.\"	The Regents of the University of California.  All rights reserved..\".\" This code is derived from software contributed to Berkeley by.\" Rodney Ruddock of the University of Guelph..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\"    notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\"    notice, this list of conditions and the following disclaimer in the.\"    documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\"    must display the following acknowledgement:.\"	This product includes software developed by the University of.\"	California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\"    may be used to endorse or promote products derived from this software.\"    without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\"	@(#)ed.1	8.1 (Berkeley) 5/31/93.\".TH ED 1 "May 31, 1993".SH NAMEed \- line oriented text editor.SH SYNOPSIS.B ed[.B \-p.I prompt-string] [.B \-s] [.B \-v] [.I filename].SH DESCRIPTION.I Edis a standard text editor..PP\fIEd\fR is a powerful line oriented editor. Although ex(1)/vi(1) have gainedpopularity, \fIed\fR still maintains advantages over them. Most notable pointsare the.I Wcommand (see below) (which is not part of ex(1)/vi(1)\|), thesmaller executable size (you can often be editing before the others finishloading), and the better response when editing from slow terminals or acrosslow baud data lines. \fIEd\fR continues to be used by many system utilities..SH OPTIONS.PPWhen a filename is present \fIed\fR starts by simulating an.I ecommand (see below)If no filename is present \fIed\fRstarts with an empty buffer.The option.B \-pallows for the setting of a prompt string in.IR ed .The option.B \-ssuppresses the printingof explanatory output(from the commands.IR e ,.IR E ,.IR r ,.IR w ,.I Wand.IR wq ;see below) and should be used with a script.The.B \-voption will display a message of which mode (BSD or POSIX).I edas been set locally. This is useful for determining the describedbehavior below..PP.I Edperforms all changes to a copy of the file which is contained in a \fBbuffer\fR.For the changes to have an effect one of the write commands (.IR w ,.IR W ,.IR wq ,or.IR Wq )must be issued..PPThe contents of the.B buffercan changed by issuing commands that are leadby zero, one, or two addresses. All commands are alphabetically listed belowwith their parameter structures if applicable; trailing structures notdescribed with commands are regarded as erroneous. Commands thataccept zero addresses regard the presence of any address as an error..PP.I Edworks in two modes: command, and input. The two modes are exclusive ofeach other. While in command mode.I edaccepts commands that display, modify, or give information about the.BR buffer .While in input mode.I edaccepts lines of text to be added to the.BR buffer ..PPAddressing in \fIed\fR specifies one or more lines contained in the.BR buffer .For commands that expect at least one address, and none are given, defaultaddresses will be used.Using addresses in.I edinvolves understanding that during the execution of most.I edcommands that a.I "current line"(.BR current )exists..B Current(as a rule of thumb) is the location in the.B bufferthat the last command issued affected; somecommands do not affect.BR current .Each command description (below) describesits affects on.B currentas the affect will vary depending under which compile option (BSD or POSIX).I edwas compiled under.Addresses can be divided into three cases: one address (\fBsingle address\fR), two addresses (an \fBaddress pair\fR),and special address forms.For the first two casesan address is formed with the use of:.TP1.A positive decimal integer (e.g. 123) indicating a line number in the buffer.Line number 1 is the first line in the buffer..TP2.The `.' character indicating the current line (\fBcurrent\fR)..TP3.The `$' character which indicates the last line in the buffer..TP4.A regular expression (RE) enclosed with `/'s as delimiters (i.e. /RE/).This causes a forward search to the first occurrence of the specified RE. Theaddress will then become this line.The character sequence \e/ escapes the forwardslash from being adelimiter.The search will wrap from the bottom ofthe buffer to the top of the buffer if need be..I EdRE's are, outside of this document, now refered to as.IR "basic regular expressions" .Basic regular expressions (BRE's), traditionally described in \fIed(1)\fR arenow fully described in regex(7). BRE's are, for the most part, the same asthe old RE's - the name has changed and the expressions extended to meetPOSIX 1003.2 specifications. (See the search command for more details.).TP5.A RE enclosed with `?'s as delimiters (i.e. ?RE?).This will cause a backward search to the first occurrence of thespecified BRE. The address will then become this line.The character sequence \e? escapes the questionmark from being adelimiter.The search will wrapfrom the top of the buffer to thebottom of the buffer if need be. (See the search command for more details.).TP6.A line previously marked by the `k' command (see below). \fB`x\fR addressesthe line marked by the single lower-case letter `\fBx\fR' (from theportable character set in the range a-z)..TP7.An address of the form 1-6 followed by a `+' followed by an integer number, .BR n ,specifies the line to be addressed is .B nlines after the address of the form1-6.If the address starts with a `+' then by default the addressed line is takenwith respect to .B current(equivalent to `.'\|; form 2).If no integer number is given then 1 is added to the address.Hence, ifmore than one `+' is given in a sequence, with no integer number following,1 is added to the address for each `+'. Therefore, +++ is eqivalent to +3,but +++1 is equivalent to +1..TP8.An address of the form 1-6 followed by a `\-' followed by an integer number,.BR n ,specifies the line to be addressed is .B nlines before the address of the form1-6.If the address starts with a `\-' then by default theaddressed line is takenwith respect to .B current(`.'\|; form 1).If no integer number is given then 1 is subtracted from the address.Hence, ifmore than one `\-' is given in a sequence, with no integer number following,1 is subtracted from the address for each `\-'. Therefore, \-\-\-is eqivalent to \-3,but \-\-\-1 is equivalent to \-1.For backward compatibility `^' is the equivalent to `\-'..TP9.A `,' (comma) may be used to separate two addresses of the form 1-8 tocreate an \fBaddress pair\fR.The first address must occur no later inthe buffer than the second address to be legal..TP10.A `;' (semicolon) may be used to separate two addresses of the form 1-8 tocreate an \fBaddress pair\fR.With this form the second address is evaluated with respect toand after the first address has been evaluated. This is useful whenaddresses of the forms 2-8 are used.The first address must occur no later inthe buffer than the second address to be legal..TPNOTE:Addresses of the forms 7 and 8 cannot be followed by addressesof forms 2-6; it is an error..PPThe following are special address forms that cannot be combinedwith any of the address forms listed above.A `,' by itself represents the address pair `1,$'.Likewise `%' by itself represents the address pair `1,$'.A `;' by itself represents the address pair `.,$'..PPThe \fIed\fR commands listed below default to the addresses prefixing thecommands. Commands without default addresses accept zero addresses.The parentheses with the default addresses are not part ofthe address; they are used to show that the addresses aredefault..PPGenerally only one command appears on a line at a time.However, many of the commands may be suffixed by `l', `n',or `p', in which casethe current line is printedin the manner discussed below.These suffixes may be combined in any order..TP 5.RB (\|.\|)\|a.br.ns.TP 5<text>.br.ns.TP 5.B ..brAppend text after the addressed line. A `.' in the first columnfollowed immediately by a <newline> places.I edback in command mode - the `.' is not included in the text. Line 0is legal for this command; text will be placed at the top of the buffer..B Currentis the last line appended (or the addressed line if no text given)..TP 5.RB (\|.\|,\|.\|)\|c.br.ns.TP 5<text>.br.ns.TP 5.B ..brChange text on the addressed line(s). The addressed lines are deletedbefore.Iedis placed in input mode. A `.' in the first columnfollowed immediately by a <newline> places.I edback in command mode - the `.' is not included in the text..B Currentis the new last line appended (or if no text is given the line afterthe addressed line deleted)..TP 5.RB (\|.\|,\|.\|)\|dDelete the addressed line(s) from the buffer. Deleted lines may berecovered with the undo command (\fIu\fR; see below)..BCurrentis the line after the last addressed line deleted..TP 5e [filename]Edit the new file `filename'. The.B bufferis cleared and the new file is placed in the.BR buffer .If the.B bufferhas been modified since the last write command.I edwill issue a warning (`?'); a second issuing ofthe command will be obeyed regardless.The number of characters read is printed (unless -s is specifiedat startup). If `filename' is missing, the rememberedname is used.If `filename' is lead by ! then it shall be interpreted as a shellcommand to be executed, from which the standard output will beplaced into the buffer; `filename' will be non-remembered.Undo will not restore the.B bufferto its state before the edit command..B Currentis the last line in the.B buffer(`$')..TP 5E [filename].I Eworks the same as.I eexcept if the buffer has been modified no warning is issued..TP 5f [filename]Print the.BR "remembered filename" .If `filename' is specified the.B "remembered filename"will be set to `filename'.If `filename' is lead by ! then it shall be interpreted as a shellcommand to be executed, from which the standard output will be used asthe new remembered filename..B Currentis unchanged..TP 5(1,$)\|g/regular expression/command listThe global command first marks all lines matchingthe regular expression.For each matching line, thecommand list is executed. At the start of each command list execution,\fBcurrent\fR is set to equal that line; \fBcurrent\fR may changeas each command in the command list is executed for that line.The first command of the command list begins on the same line asthe global command.Generally, in the command list one command occupies a line. Thus tohave multiple commands in the command list it is necessary to escape the<newline> at the end of each line so that the global command does notinterpret it as an indication that the command list entry has ended.The <newline> is escaped by proceeding it with a backslash (`\e').Similarly with the commands that set \fIed\fR into input mode the <newlines>of the entered text need to be escaped. If the `.' used to end input modeis the last line of the command list the <newline> following the `.' neednot be escaped, or the `.' may be omitted entirely.Commands in the command list can affect any line in the buffer.For the behaviour of each \fIed\fR command within a command list refer to theinformation on the individual command, particularly \fIs\fR and \fI!\fR.The commands.IR g ,.IR G ,.IR v ,.IR V ,and \fI!\fRare permitted in the command list, but should be used with caution.The command list defaults to .I pif left empty (i.e. g/RE/p).For the regular expression the delimiters can be any characters exceptfor <space> and <newline>; delimiters within a regular expression canbe escaped with a backslash preceeding it..TP 5(1,$)\|G/regular expression/.brThe interactive global command works similar to \fIg\fR. The first stepis to mark every line which matches the given regular expression.For every line matched it will print this line, set \fBcurrent\fRto this line, and accept one command (not including \fIa\fR, \fIc\fR, \fIi\fR, \fIg\fR, \fIG\fR, \fIv\fR, and \fIV\fR)for execution.The command can affect any line in the buffer. `%' by itself executesthe last non-null command.A return by itself will act as a null command. \fBCurrent\fRwill be set to the last line affected by the last successful commandinput. If no match or an input command error occurs \fBcurrent\fRwill be set to the last line searched by \fIG\fR. \fIG\fR can be prematurelyended by `ctrl-C' (SIGINT).For the behaviour of each \fIed\fR command within a command list refer to theinformation on the individual command, particularly \fIs\fR and \fI!\fR..TP 5h.brThe help command displays a message explaining the most recent commanderror (indicated by `?'). \fBCurrent\fR is unchanged..TP 5H.brThis toggles on or off the automatic display of messages explainingthe most recent command error in place of `?'. \fBCurrent\fR isunchanged..TP 5.RB (\|.\|)\|i.TP 5<text>.br.TP 5.B ..brThe insert command places.I edin input mode with the text being placed before theaddressed line. Line 0 is invalid for this command.A `.' in the first columnfollowed immediately by a return places.I edback in command mode - the `.' is not included in the text..B Currentis the last line inserted. If no text is inserted then.B currentis the addressed when.I edis compiled for POSIX; compiled for BSD,.B currentis the addressed line -1..TP 5.RB (\|.\|,\|.+1)\|jThe join command joins the addressed lines together to make oneline. If no addresses are specified.B currentand.BR current +1lines are joined.If one address only is given thenno join is performed..B Currentbecomes that line if.I edhas been compiled under the BSD option; if compiled under the POSIXoption.B currentis unchanged..TP 5( \fB. \fR)\|k\fBx\fRThe mark command marks the addressed line with label.BR x ,where

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -