• Keine Ergebnisse gefunden

Advanced Techniques

Im Dokument Ultimate Guide (Seite 78-83)

Creating Blank Lines

Breaking Lines

4-12

The line editor's basic editing features were described in the previous section. This section will present some sophisticated techniques using the basic features, particularly the searching and replacing function and the use of strings and wildcards.

A blank line (that is, a null attribute) can be created in several ways:

• If the line contains some text, the text can be replaced with a null:

. R/te:x:t on line/ /.J

• The single line I (insert) command can be used without entering data.

Type I at the prompt, followed by a single blank and RETURN. This inserts a null attribute and returns to the line editor prompt:

.I .J

• The I command can be used to enter several null attributes. For each null attribute desired, simply enter the control key sequence

<CfRL-I\> (control-caret) in the line. This has the effect of inserting an attribute mark in the text. The following example creates three blank lines:

. I <CTRL-A> <CTRL-A> <CTRL-A> .J

In the editor, each line is a separate attribute that is terminated by an attribute mark placed there by the system. Within a string, the attribute mark is the control key sequence <ClRL-I\>. When <CTRL-I\> is placed in a string, the line editor breaks the string at that point and starts a new line.

The caret prints when you type it, but the <CfRL> does not. After the buffers are flipped and the lines are listed, the caret is not displayed.

Guide to the Ultimate Editors 6939-1.2

Confidential and PfQprietary to Th6 Ultimate Corp.

o

o

6939-1.2

Advanced Techniques

The R (replace) command can be used to insert the attribute mark. For example, the following command inserts an attribute mark between characters C and D:

012 ABCDEF

.R/ABCDEF/ABC .... DEF/ .J

After flipping the buffers, the line is broken into two shorter lines:

012 ABC 013 DEF

Similarly, the following replacement inserts an attribute mark at each occurrence of the letter A on the current line (the u option causes the replacement at every occurrence of A):

RU/A/A .... / .J

For example, the previous command converts the line

023 A MACHINE THAT CAN DO ANYTHING

into the following six lines:

023 A 023+ MA

023+CHINE THA 023+T CA 023+N DO A 023+NYTHING

While inserting text, you may enter <CIRL-"> to create as many lines as desired, one line per <ClRL-"> sequence. For example, entering the following in insert mode:

002+ABC .... DEF .J

results, when the buffers are flipped, in two lines being created:

002 ABC 003 DEF

Note: The BL command can also be used to break lines. See Chapter 5 for details.

Guide to the Ultimate Editors 4-13

Confidential and Proprietary to The Ultimate Corp.

Introduction to the Line Editor

Trimming Lines

4-14

Trimming involves specialized deletion techniques. To trim a line at a specified place, include the key sequence <CfRL-_>

(control-underscore) in the replacement string of an R command. For example, if a line contains XY'ZABC, the following command truncates the line after XYZ and discards ABC:

P../XYZ/XYZ_/ J

When blanks are used as the first string in a R command, the line editor searches for a string of blanks of the same or lesser length in the line. It is therefore possible to trim all trailing blanks off an item using one of the following forms:

R/

R/

II

/<CTRL-_>

These forms assume that the blank string is longer than any string of blanks within the lines being trimmed.

The example in Figure 4-4 uses the attribute mark (A) to show the end of the text; the mark is not actually displayed.

· L2 .J

Line 1 with trailing blanks.

Line2 with trailing blanks.

/ /.J R command has more blanks than

Guide to the Ultimate Editors 6939-1.2

Confidential and Proprietary to The Ultimate Corp.

\. .1

""'"

o

(:\

It is also possible to trim the left end of a line by replacing a string of carets (wildcards) with a null, as illustrated in Figure 4-5.

032 This is a dog. That is a cat. The original line .

• R / A A A A A A A A A A A A A A A A / / Replace command.

032 That is a cat. Edited line.

Figure 4-5. Trimming the Left End of a Line

Because the R command ignores spaces preceding the fIrst string delimiter, text on a line can be easily replaced using wildcards. Go to the line to be changed. At the prompt, type the R command and space over to the column before the portion you want to change. Type the fIrst delimiter and enough of the string to make it unique, and fIll the rest with wildcards. Then type another delimiter and the replacement string.

Press RETURN. The results are shown in Figure 4-6 .

• G7.J

007 An instruction, statement, or subroutine

.R I, stAAAAAAAAAAAAAAAAAAAAAA/ o r command ~

007 An instru.ction or command

Figure 4-6. Using Wildcards to Replace Text

The ASCII character set includes both printable and non-printable characters. Characters that are not printable include the control characters, which have an ASCII hexadecimal value of 00 through IF.

The line editor displays most control key sequences as a period (.).

(The system delimiters <CTRL-">, <CTRL-]>, and <CTRL-\> are exceptions.) In normal display, the period does not indicate what the character is; however, in hexadecimal display, the actual hexadecimal value is shown.

Guide to the Ultimate Editors 4-15

Confidential and Proprietary to The Ultimate Corp.

4-16

If you do not know what the control key sequence is, it can be removed by replacing a unique string that includes the control sequence with the string of your choice. The control sequence can be marked with a caret (wildcard) in the fIrst string of the R command. Figure 4-7 replaces the control character and everything that follows it with other text.

005 The period .indicates a control key sequence.

.R /"'inAAAAAAAAAA.AAAAAAAA'AAAAAAAAAAAA lis g o n e . J

005 The period is gone.

Figure 4-7. Removing a Control Character

Guide to the Ultimate Editors 6939-1.2

Confidential and Proprietary to The Ultimate Corp.

",. ...

\,-",!

C.'"

( . " i

5

(

"'"'

/

6939-1.2

Im Dokument Ultimate Guide (Seite 78-83)