heirloom-ed

annotate ed.1 @ 2:a09d0630f05b

removed unnecessary command line options
author markus schnalke <meillo@marmaro.de>
date Tue, 12 Aug 2014 18:08:24 +0200
parents 1493bea5ac22
children ac52712b2b5e
rev   line source
meillo@0 1 '\" t
meillo@0 2 .\" Sccsid @(#)ed.1 1.48 (gritter) 6/22/05
meillo@0 3 .\" Parts taken from ed(1), Unix 7th edition:
meillo@0 4 .\" Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
meillo@0 5 .\"
meillo@0 6 .\" Redistribution and use in source and binary forms, with or without
meillo@0 7 .\" modification, are permitted provided that the following conditions
meillo@0 8 .\" are met:
meillo@0 9 .\" Redistributions of source code and documentation must retain the
meillo@0 10 .\" above copyright notice, this list of conditions and the following
meillo@0 11 .\" disclaimer.
meillo@0 12 .\" Redistributions in binary form must reproduce the above copyright
meillo@0 13 .\" notice, this list of conditions and the following disclaimer in the
meillo@0 14 .\" documentation and/or other materials provided with the distribution.
meillo@0 15 .\" All advertising materials mentioning features or use of this software
meillo@0 16 .\" must display the following acknowledgement:
meillo@0 17 .\" This product includes software developed or owned by Caldera
meillo@0 18 .\" International, Inc.
meillo@0 19 .\" Neither the name of Caldera International, Inc. nor the names of
meillo@0 20 .\" other contributors may be used to endorse or promote products
meillo@0 21 .\" derived from this software without specific prior written permission.
meillo@0 22 .\"
meillo@0 23 .\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
meillo@0 24 .\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
meillo@0 25 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
meillo@0 26 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
meillo@0 27 .\" ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE
meillo@0 28 .\" LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR
meillo@0 29 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
meillo@0 30 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
meillo@0 31 .\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
meillo@0 32 .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
meillo@0 33 .\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
meillo@0 34 .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
meillo@0 35 .TH ED 1 "6/22/05" "Heirloom Toolchest" "User Commands"
meillo@0 36 .if t .ds q \(aa
meillo@0 37 .if n .ds q '
meillo@0 38 .SH NAME
meillo@0 39 ed \- text editor
meillo@0 40 .SH SYNOPSIS
meillo@2 41 \fBed\fR [\fB\-\fR\] [\fIname\fR]
meillo@0 42 .SH DESCRIPTION
meillo@0 43 .I Ed
meillo@0 44 is the standard text editor.
meillo@0 45 .PP
meillo@0 46 If a
meillo@0 47 .I name
meillo@0 48 argument is given,
meillo@0 49 .I ed
meillo@0 50 simulates an
meillo@0 51 .I e
meillo@0 52 command (see below)\| on the named file; that is to say,
meillo@0 53 the file is read into
meillo@0 54 .IR ed 's
meillo@0 55 buffer so that it can be edited.
meillo@0 56 The optional
meillo@0 57 .B \-
meillo@0 58 suppresses the printing
meillo@0 59 of character counts by
meillo@0 60 .IR e ,
meillo@0 61 .IR r ,
meillo@0 62 and
meillo@0 63 .I w
meillo@0 64 commands,
meillo@0 65 and of the `!' after completion of a shell command.
meillo@0 66 .PP
meillo@0 67 .I Ed
meillo@0 68 operates on a copy of any file it is editing; changes made
meillo@0 69 in the copy have no effect on the file until a
meillo@0 70 .IR w ""
meillo@0 71 (write)\|
meillo@0 72 command is given.
meillo@0 73 The copy of the text being edited resides
meillo@0 74 in a temporary file called the
meillo@0 75 .IR buffer .
meillo@0 76 .PP
meillo@0 77 The editor supports format specifications as defined in
meillo@0 78 .IR fspec (5).
meillo@0 79 If the terminal is configured to expand tabulators
meillo@0 80 (as enabled with
meillo@0 81 .I stty tab3
meillo@0 82 or
meillo@0 83 .IR "stty \-tabs"),
meillo@0 84 and the first line of the file being edited
meillo@0 85 contains a format specification,
meillo@0 86 the
meillo@0 87 .I t
meillo@0 88 and
meillo@0 89 .I s
meillo@0 90 are interpreted,
meillo@0 91 that is, tabulators are expanded and lines are truncated
meillo@0 92 when printing to the terminal. For example,
meillo@0 93 .RS
meillo@0 94 <:t\-f s72:>
meillo@0 95 .sp
meillo@0 96 .RE
meillo@0 97 selects FORTRAN format and truncates lines at 72 characters.
meillo@0 98 No expansion or truncation is performed by
meillo@0 99 .I ed
meillo@0 100 when input is typed to the terminal.
meillo@0 101 .PP
meillo@0 102 Commands to
meillo@0 103 .I ed
meillo@0 104 have a simple and regular structure: zero or
meillo@0 105 more
meillo@0 106 .I addresses
meillo@0 107 followed by a single character
meillo@0 108 .I command,
meillo@0 109 possibly
meillo@0 110 followed by parameters to the command.
meillo@0 111 These addresses specify one or more lines in the buffer.
meillo@0 112 Missing addresses are supplied by default.
meillo@0 113 .PP
meillo@0 114 In general, only one command may appear on a line.
meillo@0 115 Certain commands allow the
meillo@0 116 addition of text to the buffer.
meillo@0 117 While
meillo@0 118 .I ed
meillo@0 119 is accepting text, it is said
meillo@0 120 to be in
meillo@0 121 .I "input mode."
meillo@0 122 In this mode, no commands are recognized;
meillo@0 123 all input is merely collected.
meillo@0 124 Input mode is left by typing a period `\fB.\fR' alone at the
meillo@0 125 beginning of a line.
meillo@0 126 .PP
meillo@0 127 .I Ed
meillo@0 128 supports a limited form of
meillo@0 129 .I "regular expression"
meillo@0 130 notation.
meillo@0 131 A regular expression specifies
meillo@0 132 a set of strings of characters.
meillo@0 133 A member of this set of strings is said to be
meillo@0 134 .I matched
meillo@0 135 by the regular expression.
meillo@0 136 In the following specification for regular expressions
meillo@0 137 the word `character' means any character but newline.
meillo@0 138 .B ed
meillo@0 139 uses simple regular expressions.
meillo@0 140 .SS "Simple Regular Expressions"
meillo@0 141 .IP 1.
meillo@0 142 Any character except a special character
meillo@0 143 matches itself.
meillo@0 144 Special characters are
meillo@0 145 the regular expression delimiter plus
meillo@0 146 .RB \e\|[\| .
meillo@0 147 and sometimes ^\|*\|$.
meillo@0 148 .IP 2.
meillo@0 149 A
meillo@0 150 .B .\&
meillo@0 151 matches any character.
meillo@0 152 .IP 3.
meillo@0 153 A \fB\e\fR followed by any character except a digit
meillo@0 154 or (\|) {\|} <\|> matches that character.
meillo@0 155 .IP 4.
meillo@0 156 A nonempty string
meillo@0 157 .I s
meillo@0 158 bracketed
meillo@0 159 \fB[\fI\|s\|\fB]\fR
meillo@0 160 (or
meillo@0 161 \fB[^\fIs\|\fB]\fR)
meillo@0 162 forms a \fIbracket expression\fR that
meillo@0 163 matches any character in (or not in)
meillo@0 164 .I s.
meillo@0 165 In
meillo@0 166 .I s,
meillo@0 167 \e has no special meaning, and ] may only appear as
meillo@0 168 the first letter.
meillo@0 169 A substring
meillo@0 170 \fIa\fB\-\fIb\fR,
meillo@0 171 with
meillo@0 172 .I a
meillo@0 173 and
meillo@0 174 .I b
meillo@0 175 in ascending ASCII order, stands for the inclusive
meillo@0 176 range of ASCII characters.
meillo@0 177 .IP 5.
meillo@0 178 A regular expression of form 1-4 followed by \fB*\fR matches a sequence of
meillo@0 179 0 or more matches of the regular expression.
meillo@0 180 .IP 6.
meillo@0 181 A regular expression of form 1-4
meillo@0 182 followed by \fB\e{\fIm\fB,\fIn\fB\e}\fR
meillo@0 183 forms an \fIinterval expression\fR that
meillo@0 184 matches a sequence of \fIm\fR through \fIn\fR matches, inclusive,
meillo@0 185 of the regular expression.
meillo@0 186 The values of \fIm\fR and \fIn\fR must be non-negative
meillo@0 187 and smaller than 256.
meillo@0 188 The form \fB\e{\fIm\fB\e}\fR matches exactly \fIm\fR occurrences,
meillo@0 189 \fB\e{\fIm\fB,\e}\fR matches at least \fIm\fR occurrences.
meillo@0 190 .IP 7.
meillo@0 191 The sequence \fB\e<\fR forces the match
meillo@0 192 to occur only at the beginning of a ``variable'' or ``word'';
meillo@0 193 that is, either at the beginning of a line,
meillo@0 194 or just before a letter, digit or underline
meillo@0 195 and after a character not one of these.
meillo@0 196 .IP 8.
meillo@0 197 The sequence \fB\e>\fR matches the end
meillo@0 198 of a ``variable'' or ``word'',
meillo@0 199 i.\|e. either the end of the line
meillo@0 200 or before character which is neither a letter,
meillo@0 201 nor a digit, nor the underline character.
meillo@0 202 .IP 9.
meillo@0 203 A regular expression,
meillo@0 204 .I x,
meillo@0 205 of form 1-11, parenthesized
meillo@0 206 \fB\e(\fI\|x\|\fB\e)\fR
meillo@0 207 is called a \fIsubexpression\fR and
meillo@0 208 matches what
meillo@0 209 .I x
meillo@0 210 matches.
meillo@0 211 .IP 10.
meillo@0 212 A \fB\e\fR followed by a digit
meillo@0 213 .I n
meillo@0 214 forms a \fIbackreference\fR and
meillo@0 215 matches a copy of the string that the
meillo@0 216 parenthesized regular expression beginning with the
meillo@0 217 .IR n th
meillo@0 218 \e( matched.
meillo@0 219 .IP 11.
meillo@0 220 A regular expression of form 1-11,
meillo@0 221 .I x,
meillo@0 222 followed by a regular expression of form 1-10,
meillo@0 223 .I y
meillo@0 224 matches a match for
meillo@0 225 .I x
meillo@0 226 followed by a match for
meillo@0 227 .I y,
meillo@0 228 with the
meillo@0 229 .I x
meillo@0 230 match being as long as possible while still permitting a
meillo@0 231 .I y
meillo@0 232 match.
meillo@0 233 .IP 12.
meillo@0 234 A regular expression of form 1-11 preceded by \fB^\fR
meillo@0 235 (or followed by \fB$\fR), is constrained to matches that
meillo@0 236 begin at the left (or end at the right) end of a line
meillo@0 237 (\fIanchoring\fR).
meillo@0 238 .IP 13.
meillo@0 239 A regular expression of form 1-12 picks out the
meillo@0 240 longest among the leftmost matches in a line.
meillo@0 241 .IP 14.
meillo@0 242 An empty regular expression stands for a copy of the
meillo@0 243 last regular expression encountered.
meillo@0 244 .PP
meillo@0 245 Regular expressions are used in addresses to specify
meillo@0 246 lines and in one command
meillo@0 247 (see
meillo@0 248 .I s
meillo@0 249 below)\|
meillo@0 250 to specify a portion of a line which is to be replaced.
meillo@0 251 If it is desired to use one of
meillo@0 252 the regular expression metacharacters as an ordinary
meillo@0 253 character, that character may be preceded by `\e'.
meillo@0 254 This also applies to the character bounding the regular
meillo@0 255 expression (often `/')\| and to `\e' itself.
meillo@0 256 .PP
meillo@0 257 To understand addressing in
meillo@0 258 .I ed
meillo@0 259 it is necessary to know that at any time there is a
meillo@0 260 .I "current line."
meillo@0 261 Generally speaking, the current line is
meillo@0 262 the last line affected by a command; however,
meillo@0 263 the exact effect on the current line
meillo@0 264 is discussed under the description of
meillo@0 265 the command.
meillo@0 266 Addresses are constructed as follows.
meillo@0 267 .TP
meillo@0 268 1.
meillo@0 269 The character `\fB.\fR' addresses the current line.
meillo@0 270 .TP
meillo@0 271 2.
meillo@0 272 The character `\fB$\fR' addresses the last line of the buffer.
meillo@0 273 .TP
meillo@0 274 3.
meillo@0 275 A decimal number
meillo@0 276 .I n
meillo@0 277 addresses the
meillo@0 278 .IR n -th
meillo@0 279 line of the buffer.
meillo@0 280 .TP
meillo@0 281 4.
meillo@0 282 `\fB\(fm\fIx\fR' addresses the line marked with the name
meillo@0 283 .IR x ,
meillo@0 284 which must be a lower-case letter.
meillo@0 285 Lines are marked with the
meillo@0 286 .I k
meillo@0 287 command described below.
meillo@0 288 .TP
meillo@0 289 5.
meillo@0 290 A regular expression enclosed in slashes `\fB/\fR' addresses
meillo@0 291 the line found by searching forward from the current line
meillo@0 292 and stopping at the first line containing a
meillo@0 293 string that matches the regular expression.
meillo@0 294 If necessary the search wraps around to the beginning of the
meillo@0 295 buffer.
meillo@0 296 .TP
meillo@0 297 6.
meillo@0 298 A regular expression enclosed in queries `\fB?\fR' addresses
meillo@0 299 the line found by searching backward from the current line
meillo@0 300 and stopping at the first line containing
meillo@0 301 a string that matches the regular expression.
meillo@0 302 If necessary
meillo@0 303 the search wraps around to the end of the buffer.
meillo@0 304 .TP
meillo@0 305 7.
meillo@0 306 An address followed by a plus sign `\fB+\fR'
meillo@0 307 or a minus sign `\fB\-\fR' followed by a decimal number
meillo@0 308 specifies that address plus
meillo@0 309 (resp. minus)\| the indicated number of lines.
meillo@0 310 The plus sign may be omitted.
meillo@0 311 .TP
meillo@0 312 8.
meillo@0 313 If an address begins with `\fB+\fR' or `\fB\-\fR'
meillo@0 314 the addition or subtraction is taken with respect to the current line;
meillo@0 315 e.g. `\-5' is understood to mean `\fB.\fR\-5'.
meillo@0 316 .TP
meillo@0 317 9.
meillo@0 318 If an address ends with `\fB+\fR' or `\fB\-\fR',
meillo@0 319 then 1 is added (resp. subtracted).
meillo@0 320 As a consequence of this rule and rule 8,
meillo@0 321 the address `\-' refers to the line before the current line.
meillo@0 322 Moreover,
meillo@0 323 trailing
meillo@0 324 `+' and `\-' characters
meillo@0 325 have cumulative effect, so `\-\-' refers to the current
meillo@0 326 line less 2.
meillo@0 327 .TP
meillo@0 328 10.
meillo@0 329 To maintain compatibility with earlier versions of the editor,
meillo@0 330 the character `\fB^\fR' in addresses is
meillo@0 331 equivalent to `\-'.
meillo@0 332 .PP
meillo@0 333 Commands may require zero, one, or two addresses.
meillo@0 334 Commands which require no addresses regard the presence
meillo@0 335 of an address as an error.
meillo@0 336 Commands which accept one or two addresses
meillo@0 337 assume default addresses when insufficient are given.
meillo@0 338 If more addresses are given than such a command requires,
meillo@0 339 the last one or two (depending on what is accepted)\| are used.
meillo@0 340 .PP
meillo@0 341 Addresses are separated from each other typically by a comma
meillo@0 342 `\fB,\fR'.
meillo@0 343 They may also be separated by a semicolon
meillo@0 344 `\fB;\fR'.
meillo@0 345 In this case the current line `\fB.\fR' is set to
meillo@0 346 the previous address before the next address is interpreted.
meillo@0 347 This feature can be used to determine the starting
meillo@0 348 line for forward and backward searches (`/', `?')\|.
meillo@0 349 The second address of any two-address sequence
meillo@0 350 must correspond to a line following the line corresponding to the first address.
meillo@0 351 .PP
meillo@0 352 Omission of the first address causes
meillo@0 353 the first line to be used with `,',
meillo@0 354 or the current line with `;', respectively;
meillo@0 355 if the second address is also omitted,
meillo@0 356 the last line of the buffer is used.
meillo@0 357 Thus a single `,' specifies the entire contents of the buffer,
meillo@0 358 and a single `;' specifies the contents
meillo@0 359 ranging from the current line to the last one.
meillo@0 360 .PP
meillo@0 361 In the following list of
meillo@0 362 .I ed
meillo@0 363 commands, the default addresses
meillo@0 364 are shown in parentheses.
meillo@0 365 The parentheses are not part of
meillo@0 366 the address, but are used to show that the given addresses are
meillo@0 367 the default.
meillo@0 368 .PP
meillo@0 369 As mentioned, it is generally illegal for more than one
meillo@0 370 command to appear on a line.
meillo@0 371 However, most commands may be suffixed by `p', `l', or `n',
meillo@0 372 in which case
meillo@0 373 the current line is either
meillo@0 374 printed, listed, or numbered respectively
meillo@0 375 in the way discussed below.
meillo@0 376 .TP 5
meillo@0 377 \fR(\|\fI.\|\fR)\fB\|a\fR
meillo@0 378 .br
meillo@0 379 .ns
meillo@0 380 .TP 5
meillo@0 381 <text>
meillo@0 382 .br
meillo@0 383 .ns
meillo@0 384 .TP 5
meillo@0 385 .B .
meillo@0 386 .br
meillo@0 387 The append command reads the given text
meillo@0 388 and appends it after the addressed line.
meillo@0 389 `\fB.\fR' is left
meillo@0 390 on the last line input, if there
meillo@0 391 were any, otherwise at the addressed line.
meillo@0 392 Address `0' is legal for this command; text is placed
meillo@0 393 at the beginning of the buffer.
meillo@0 394 .TP 5
meillo@0 395 \fR(\|\fI.\|\fB,\|\fI.\|\fR)\|\fBc\fR
meillo@0 396 .br
meillo@0 397 .ns
meillo@0 398 .TP 5
meillo@0 399 <text>
meillo@0 400 .br
meillo@0 401 .ns
meillo@0 402 .TP 5
meillo@0 403 .B .
meillo@0 404 .br
meillo@0 405 The change
meillo@0 406 command deletes the addressed lines, then accepts input
meillo@0 407 text which replaces these lines.
meillo@0 408 `\fB.\fR' is left at the last line input; if there were none,
meillo@0 409 it is left at the line preceding the deleted lines.
meillo@0 410 .TP 5
meillo@0 411 \fR(\|\fI.\|\fB,\|\fI.\|\fR)\|\fBd\fR
meillo@0 412 The delete command deletes the addressed lines from the buffer.
meillo@0 413 The line originally after the last line deleted becomes the current line;
meillo@0 414 if the lines deleted were originally at the end,
meillo@0 415 the new last line becomes the current line.
meillo@0 416 .TP 5
meillo@0 417 \fBe\ \fIfilename\fR
meillo@0 418 The edit
meillo@0 419 command causes the entire contents of the buffer to be deleted,
meillo@0 420 and then the named file to be read in.
meillo@0 421 `\fB.\fR' is set to the last line of the buffer.
meillo@0 422 The number of characters read is typed.
meillo@0 423 `\fIfilename\fR' is remembered for possible use as a default file name
meillo@0 424 in a subsequent
meillo@0 425 .I r
meillo@0 426 or
meillo@0 427 .I w
meillo@0 428 command.
meillo@0 429 If `\fIfilename\fR' is missing, the remembered name is used.
meillo@0 430 A `\fIfilename\fR' starting with a `\fB!\fR'
meillo@0 431 causes the output of the shell command following this character
meillo@0 432 to be read in.
meillo@0 433 .TP 5
meillo@0 434 \fBE\ \fIfilename\fR
meillo@0 435 This command is the same as
meillo@0 436 .IR e ,
meillo@0 437 except that no diagnostic results when no
meillo@0 438 .I w
meillo@0 439 has been given since the last buffer alteration.
meillo@0 440 .TP 5
meillo@0 441 \fBf\ \fIfilename\fR
meillo@0 442 The filename command prints the currently remembered file name.
meillo@0 443 If `\fIfilename\fR' is given,
meillo@0 444 the currently remembered file name is changed to `\fIfilename\fR'.
meillo@0 445 .TP 5
meillo@0 446 \fR(\fI1\fB,\fI$\fR)\|\fBg/\fIregular expression\fB/\fIcommand list\fR
meillo@0 447 In the global
meillo@0 448 command, the first step is to mark every line which matches
meillo@0 449 the given \fIregular expression\fR.
meillo@0 450 Then for every such line, the
meillo@0 451 given \fIcommand list\fR is executed
meillo@0 452 with `\fB.\fR' initially set to that line.
meillo@0 453 A single command or the first of multiple commands
meillo@0 454 appears on the same line with the global command.
meillo@0 455 All lines of a multi-line list except the last line must be ended with `\e'.
meillo@0 456 .I A,
meillo@0 457 .I i,
meillo@0 458 and
meillo@0 459 .I c
meillo@0 460 commands and associated input are permitted;
meillo@0 461 the `\fB.\fR' terminating input mode may be omitted if it would be on the
meillo@0 462 last line of the command list.
meillo@0 463 The commands
meillo@0 464 .I g
meillo@0 465 and
meillo@0 466 .I v
meillo@0 467 are not permitted in the command list.
meillo@0 468 .TP 5
meillo@0 469 \fR(\fI1\fB,\fI$\fR)\|\fBG/\fIregular expression\fB/\fR
meillo@0 470 The interactive global command
meillo@0 471 first marks every line matching the given \fIregular expression\fR.
meillo@0 472 Then each line is printed
meillo@0 473 and a command is read and executed for this line.
meillo@0 474 A single newline character causes the line to remain unchanged,
meillo@0 475 an isolated `\fB&\fR' repeats the command given for the previous line.
meillo@0 476 The command can be terminated by an interrupt signal.
meillo@0 477 .TP 5
meillo@0 478 .B h
meillo@0 479 This command prints a verbose description for the
meillo@0 480 last error encountered.
meillo@0 481 .TP
meillo@0 482 .B H
meillo@0 483 This command acts like the
meillo@0 484 .I h
meillo@0 485 command,
meillo@0 486 but also causes verbose descriptions to be printed
meillo@0 487 on all following error conditions.
meillo@0 488 Another
meillo@0 489 .I H
meillo@0 490 turns verbose mode off.
meillo@0 491 .TP 5
meillo@0 492 \fR(\|\fI.\|\fR)\|\fBi\fR
meillo@0 493 .br
meillo@0 494 .ns
meillo@0 495 .TP 5
meillo@0 496 <text>
meillo@0 497 .br
meillo@0 498 .ns
meillo@0 499 .TP 5
meillo@0 500 .B .
meillo@0 501 .br
meillo@0 502 This command inserts the given text before the addressed line.
meillo@0 503 `\fB.\fR' is left at the last line input, or, if there were none,
meillo@0 504 at the line before the addressed line.
meillo@0 505 This command differs from the
meillo@0 506 .I a
meillo@0 507 command only in the placement of the
meillo@0 508 text.
meillo@0 509 .TP 5
meillo@0 510 \fR(\|\fI.\|\fB,\|\fI.+1\fR)\|\fBj\fR
meillo@0 511 This command joins the addressed lines into a single line;
meillo@0 512 intermediate newlines simply disappear.
meillo@0 513 `\fB.\fR' is left at the resulting line.
meillo@0 514 .TP 5
meillo@0 515 \fR(\fI.\fR)\|\fBk\fIx\fR
meillo@0 516 The mark command marks the addressed line with
meillo@0 517 name
meillo@0 518 .IR x ,
meillo@0 519 which must be a lower-case letter.
meillo@0 520 The address form `\(fm\fIx\fR' then addresses this line.
meillo@0 521 .ne 2.5
meillo@0 522 .TP 5
meillo@0 523 \fR(\|\fI.\|\fB,\|\fI.\|\fR)\|\fBl\fR
meillo@0 524 The list command
meillo@0 525 prints the addressed lines in an unambiguous way:
meillo@0 526 non-graphic control characters are printed in three-digit octal;
meillo@0 527 Long lines are folded.
meillo@0 528 The
meillo@0 529 .I l
meillo@0 530 command may be placed on the same line after any non-i/o
meillo@0 531 command.
meillo@0 532 .TP 5
meillo@0 533 \fR(\|\fI.\|\fB,\|\fI.\|\fR)\|\fBm\fIa\fR
meillo@0 534 The move command repositions the addressed lines after the line
meillo@0 535 addressed by
meillo@0 536 .IR a .
meillo@0 537 The last of the moved lines becomes the current line.
meillo@0 538 .TP 5
meillo@0 539 \fR(\|\fI.\|\fB,\|\fI.\|\fR)\|\fBn\fR
meillo@0 540 This command prints lines preceded by their line numbers.
meillo@0 541 It otherwise acts like the
meillo@0 542 .I p
meillo@0 543 command described below.
meillo@0 544 .TP 5
meillo@0 545 \fR(\|\fI.\|\fB,\|\fI.\|\fR)\|\fBp\fR
meillo@0 546 The print command prints the addressed lines.
meillo@0 547 `\fB.\fR'
meillo@0 548 is left at the last line printed.
meillo@0 549 The
meillo@0 550 .I p
meillo@0 551 command
meillo@0 552 may
meillo@0 553 be placed on the same line after any non-i/o command.
meillo@0 554 .TP
meillo@0 555 .B P
meillo@0 556 This command causes a prompt to be printed
meillo@0 557 before following commands are read.
meillo@2 558 The default prompt is a `*' character.
meillo@0 559 Another
meillo@0 560 .I P
meillo@0 561 disables the prompt.
meillo@0 562 .TP 5
meillo@0 563 .B q
meillo@0 564 The quit command causes
meillo@0 565 .I ed
meillo@0 566 to exit.
meillo@0 567 No automatic write
meillo@0 568 of a file is done.
meillo@0 569 .TP 5
meillo@0 570 .B Q
meillo@0 571 This command is the same as
meillo@0 572 .I q,
meillo@0 573 except that no diagnostic results when no
meillo@0 574 .I w
meillo@0 575 has been given since the last buffer alteration.
meillo@0 576 .TP 5
meillo@0 577 \fR(\fI$\fR)\|\fBr\ \fIfilename\fR
meillo@0 578 The read command
meillo@0 579 reads in the given file after the addressed line.
meillo@0 580 If no file name is given,
meillo@0 581 the remembered file name, if any, is used
meillo@0 582 (see
meillo@0 583 .I e
meillo@0 584 and
meillo@0 585 .I f
meillo@0 586 commands)\|.
meillo@0 587 The file name is remembered if there was no
meillo@0 588 remembered file name already.
meillo@0 589 Address `0' is legal for
meillo@0 590 .I r
meillo@0 591 and causes the
meillo@0 592 file to be read at the beginning of the buffer.
meillo@0 593 If the read is successful, the number of characters
meillo@0 594 read is typed.
meillo@0 595 `\fB.\fR' is left at the last line read in from the file.
meillo@0 596 A `filename' starting with a `\fB!\fR'
meillo@0 597 causes the output of the shell command following this character
meillo@0 598 to be read in.
meillo@0 599 .TP 5
meillo@0 600 \fR(\|\fI.\fB\|,\|\fI.\fR\|)\|\fBs/\fIregular expression\fB/\fIreplacement\fB/\fR or,
meillo@0 601 .br
meillo@0 602 .ns
meillo@0 603 .TP 5
meillo@0 604 \fR(\|\fI.\fB\|,\|\fI.\fR\|)\|\fBs/\fIregular expression\fB/\fIreplacement\fB/g\fR or,
meillo@0 605 .br
meillo@0 606 .ns
meillo@0 607 .TP 5
meillo@0 608 \fR(\|\fI.\fB\|,\|\fI.\fR\|)\|\fBs/\fIregular expression\fB/\fIreplacement\fB/\fInumber\fR
meillo@0 609 The substitute command searches each addressed
meillo@0 610 line for an occurrence of the specified regular expression.
meillo@0 611 On each line in which a match is found,
meillo@0 612 all matched strings are replaced by the replacement specified,
meillo@0 613 if the global replacement indicator
meillo@0 614 .RB ` g '
meillo@0 615 appears after the command.
meillo@0 616 If the global indicator does not appear, only the first occurrence
meillo@0 617 of the matched string is replaced;
meillo@0 618 if the \fInumber\fR indicator is given,
meillo@0 619 the numbered occurrence is replaced.
meillo@0 620 It is an error for the substitution to fail on all addressed lines.
meillo@0 621 Any character other than space or new-line
meillo@0 622 may be used instead of `/' to delimit the regular expression
meillo@0 623 and the replacement.
meillo@0 624 `\fB.\fR' is left at the last line substituted.
meillo@0 625 .IP
meillo@0 626 An ampersand
meillo@0 627 .RB ` & '
meillo@0 628 appearing in the replacement
meillo@0 629 is replaced by the string matching the regular expression.
meillo@0 630 The special meaning of `&' in this context may be
meillo@0 631 suppressed by preceding it by
meillo@0 632 .RB ` \e '.
meillo@0 633 The characters `\|\fB\e\fIn\fR'
meillo@0 634 where
meillo@0 635 .I n
meillo@0 636 is a digit,
meillo@0 637 are replaced by the text matched by the
meillo@0 638 .IR n -th
meillo@0 639 regular subexpression
meillo@0 640 enclosed between `\e(' and `\e)'.
meillo@0 641 When
meillo@0 642 nested, parenthesized subexpressions
meillo@0 643 are present,
meillo@0 644 .I n
meillo@0 645 is determined by counting occurrences of `\e(' starting from the left.
meillo@0 646 .IP
meillo@0 647 A substitution string consisting of a single
meillo@0 648 .RB ` % '
meillo@0 649 causes the string given on the previous substitution to be re-used.
meillo@0 650 .IP
meillo@0 651 Lines may be split by substituting new-line characters into them.
meillo@0 652 The new-line in the
meillo@0 653 replacement string
meillo@0 654 must be escaped by preceding it by
meillo@0 655 .RB ` \e '.
meillo@0 656 .TP 5
meillo@0 657 \fR(\|\fI.\|\fB,\|\fI.\|\fR)\|\fBt\|\fIa\fR
meillo@0 658 This command acts just like the
meillo@0 659 .I m
meillo@0 660 command, except that a copy of the addressed lines is placed
meillo@0 661 after address
meillo@0 662 .I a
meillo@0 663 (which may be 0).
meillo@0 664 `\fB.\fR' is left on the last line of the copy.
meillo@0 665 .TP 5
meillo@0 666 .B u
meillo@0 667 The undo command restores
meillo@0 668 the contents of the buffer
meillo@0 669 before the last command was executed.
meillo@0 670 If the undo command is given twice,
meillo@0 671 the current state is restored.
meillo@0 672 .TP 5
meillo@0 673 \fR(\fI1\fB,\fI$\fR)\|\fBv/\fIregular expression\fB/\fIcommand list\fR
meillo@0 674 This command is the same as the global command
meillo@0 675 .I g
meillo@0 676 except that the command list is executed
meillo@0 677 .I g
meillo@0 678 with `\fB.\fR' initially set to every line
meillo@0 679 .I except
meillo@0 680 those
meillo@0 681 matching the regular expression.
meillo@0 682 .TP 5
meillo@0 683 \fR(\fI1\fB,\fI$\fR)\|\fBV/\fIregular expression\fB/\fR
meillo@0 684 This command is the same as the interactive global command
meillo@0 685 .I G
meillo@0 686 except that the commands are read
meillo@0 687 .I g
meillo@0 688 with `\fB.\fR' initially set to every line
meillo@0 689 .I except
meillo@0 690 those
meillo@0 691 matching the regular expression.
meillo@0 692 .TP 5
meillo@0 693 \fR(\fI1\fB,\fI$\fR)\|\fBw\ \fIfilename\fR
meillo@0 694 .br
meillo@0 695 The write command writes the addressed lines onto
meillo@0 696 the given file.
meillo@0 697 If the file does not exist,
meillo@0 698 it is created mode 666 (readable and writable by everyone)\|.
meillo@0 699 The file name is remembered if there was no
meillo@0 700 remembered file name already.
meillo@0 701 If no file name is given,
meillo@0 702 the remembered file name, if any, is used
meillo@0 703 (see
meillo@0 704 .I e
meillo@0 705 and
meillo@0 706 .I f
meillo@0 707 commands)\|.
meillo@0 708 `\fB.\fR' is unchanged.
meillo@0 709 If the command is successful, the number of characters written is
meillo@0 710 printed.
meillo@0 711 A `filename' starting with a `\fB!\fR'
meillo@0 712 causes the string following this character
meillo@0 713 to be executed as a shell command
meillo@0 714 with the addressed lines as standard input.
meillo@0 715 .TP
meillo@0 716 \fR(\fI1\fB,\fI$\fR)\fBW\ \fIfilename\fR
meillo@0 717 This command is the same as
meillo@0 718 .I w,
meillo@0 719 except that the addressed lines are appended to the file.
meillo@0 720 .TP 5
meillo@0 721 \fR(\fI$\fR)\|\fB=\fR
meillo@0 722 The line number of the addressed line is typed.
meillo@0 723 `\fB.\fR' is unchanged by this command.
meillo@0 724 .TP 5
meillo@0 725 \fB!\fR<shell command>
meillo@0 726 The remainder of the line after the `!' is sent
meillo@0 727 to
meillo@0 728 .IR sh (1)
meillo@0 729 to be interpreted as a command.
meillo@0 730 .RB ` . '
meillo@0 731 is unchanged.
meillo@0 732 If the command starts with a
meillo@0 733 .RB ` ! ',
meillo@0 734 the previous command is inserted.
meillo@0 735 A
meillo@0 736 .RB ` % '
meillo@0 737 causes the current file name to be inserted.
meillo@0 738 .TP 5
meillo@0 739 \fR(\|\fI.+1\fR)\|<newline>
meillo@0 740 An address alone on a line causes the addressed line to be printed.
meillo@0 741 A blank line alone is equivalent to `.+1p'; it is useful
meillo@0 742 for stepping through text.
meillo@0 743 .PP
meillo@0 744 The following commands are extensions:
meillo@0 745 .TP 5
meillo@0 746 \fR(\|\fI.\|\fR)\fB\|b\fR[\fIcount\fR]
meillo@0 747 Prints a screenful of lines,
meillo@0 748 starting at the addressed one,
meillo@0 749 and browses forward in the buffer by this amount.
meillo@0 750 With the optional
meillo@0 751 .I count
meillo@0 752 argument, the screen size for this and following
meillo@0 753 .I b
meillo@0 754 commands is set to the given number of lines.
meillo@0 755 .TP 5
meillo@0 756 .B help
meillo@0 757 Causes a summary of
meillo@0 758 .I ed
meillo@0 759 commands along with short descriptions
meillo@0 760 to be printed on the terminal.
meillo@0 761 .TP 5
meillo@0 762 .B N
meillo@0 763 Makes the
meillo@0 764 .I p
meillo@0 765 command behave like the
meillo@0 766 .I n
meillo@0 767 command and vice-versa.
meillo@0 768 If given a second time,
meillo@0 769 the original semantics are restored.
meillo@0 770 .TP 5
meillo@0 771 \fR(\|\fI.\|\fR)\fB\|o\fR[\fIcount\fR]
meillo@0 772 Prints a screenful of lines centered around the addressed one.
meillo@0 773 The current line is not changed.
meillo@0 774 With the optional
meillo@0 775 .I count
meillo@0 776 argument, the amount of lines printed above and below
meillo@0 777 for this and following
meillo@0 778 .I o
meillo@0 779 commands is set to the given number.
meillo@0 780 .TP 5
meillo@0 781 .B z
meillo@0 782 Performs the same actions as a
meillo@0 783 .I w
meillo@0 784 command followed by a
meillo@0 785 .I q
meillo@0 786 command.
meillo@0 787 .PP
meillo@0 788 If an interrupt signal is sent,
meillo@0 789 .I ed
meillo@0 790 prints a `?' and returns to its command level.
meillo@0 791 .PP
meillo@0 792 An input line that consists exactly of the two characters `\e.'
meillo@0 793 causes a period `.' to be inserted with the
meillo@0 794 .IR a ,
meillo@0 795 .IR c ,
meillo@0 796 and
meillo@0 797 .IR i
meillo@0 798 commands.
meillo@0 799 .PP
meillo@0 800 Some size limitations:
meillo@0 801 The maximum number of bytes in the buffer
meillo@0 802 corresponds to the address size;
meillo@0 803 on machines with 32-bit addressing,
meillo@0 804 it is 2\ G bytes,
meillo@0 805 with 64-bit addressing,
meillo@0 806 it is 9\ E bytes.
meillo@0 807 The limit on the number of lines depends on the amount of core:
meillo@0 808 each line takes 2 words.
meillo@0 809 .PP
meillo@0 810 If a line contains a NUL character,
meillo@0 811 regular expressions cannot match beyond this character.
meillo@0 812 A substitute command deletes a NUL
meillo@0 813 and all following characters on the line.
meillo@0 814 NUL characters in command input are discarded.
meillo@0 815 If an input file does not end with a newline,
meillo@0 816 .I ed
meillo@0 817 prints a message and appends one.
meillo@0 818 .PP
meillo@0 819 Omission of the `/' character
meillo@0 820 following the regular expression or the replacement string
meillo@0 821 to the global and substitute commands
meillo@0 822 causes the affected lines to be printed.
meillo@0 823 Thus the following commands have the same effect:
meillo@0 824 .RS
meillo@0 825 g/pattern g/pattern/p
meillo@0 826 .br
meillo@0 827 s/pattern/repl s/pattern/repl/p
meillo@0 828 .br
meillo@0 829 s/pattern/ s/pattern//p
meillo@0 830 .RE
meillo@0 831 .SH "ENVIRONMENT VARIABLES"
meillo@0 832 .TP
meillo@0 833 .BR LANG ", " LC_ALL
meillo@0 834 See
meillo@0 835 .IR locale (7).
meillo@0 836 .TP
meillo@0 837 .B LC_CTYPE
meillo@0 838 Determines the mapping of bytes to characters
meillo@0 839 and the set of printable characters for the
meillo@0 840 .I l
meillo@0 841 command.
meillo@0 842 .TP
meillo@0 843 .B TMPDIR
meillo@0 844 Determines the location of the temporary file
meillo@0 845 if it contains the name of an accessible directory.
meillo@0 846 .SH FILES
meillo@0 847 /var/tmp/e*
meillo@0 848 .br
meillo@0 849 /tmp/e*
meillo@0 850 .br
meillo@0 851 ed.hup: work is saved here if terminal hangs up
meillo@0 852 .SH "SEE ALSO"
meillo@0 853 B. W. Kernighan,
meillo@0 854 .I
meillo@0 855 A Tutorial Introduction to the ED Text Editor
meillo@0 856 .br
meillo@0 857 B. W. Kernighan,
meillo@0 858 .I Advanced editing on UNIX
meillo@0 859 .br
meillo@0 860 bfs(1),
meillo@0 861 grep(1),
meillo@0 862 sed(1),
meillo@0 863 sh(1)
meillo@0 864 .SH DIAGNOSTICS
meillo@0 865 `?name' for inaccessible file;
meillo@0 866 `?' for
meillo@0 867 errors in commands,
meillo@0 868 possibly followed by a verbose description
meillo@0 869 (see the description for the
meillo@0 870 .I h
meillo@0 871 and
meillo@0 872 .I H
meillo@0 873 commands above).
meillo@0 874 .PP
meillo@0 875 To protect against throwing away valuable work,
meillo@0 876 a
meillo@0 877 .I q
meillo@0 878 or
meillo@0 879 .I e
meillo@0 880 command is considered to be in error, unless a
meillo@0 881 .I w
meillo@0 882 has occurred since the last buffer change.
meillo@0 883 A second
meillo@0 884 .I q
meillo@0 885 or
meillo@0 886 .I e
meillo@0 887 will be obeyed regardless.
meillo@0 888 .SH NOTES
meillo@0 889 A
meillo@0 890 .I !\&
meillo@0 891 command cannot be subject to a
meillo@0 892 .I g
meillo@0 893 command.
meillo@0 894 .PP
meillo@0 895 The LC_COLLATE variable has currently no effect.
meillo@0 896 Ranges in bracket expressions are ordered
meillo@0 897 as byte values in single-byte locales
meillo@0 898 and as wide character values in multibyte locales.
meillo@0 899 .PP
meillo@0 900 For portable programs, restrict textual data
meillo@0 901 to the US-ASCII character set and
meillo@0 902 set the LC_CTYPE and LC_COLLATE variables to `C' or `POSIX'.