heirloom-ed

annotate ed.1 @ 3:ac52712b2b5e

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