• Keine Ergebnisse gefunden

Append or Insert Mode

Im Dokument XE 500 (Seite 106-112)

One of the most useful commands is the insert (i) command.

After typing i, everything typed until you press the GO key is inserted into the file. If you are on a dumb terminal, it will seem that some of the characters in your line have been overwritten; but they will reappear when you press the GO key. A similar command is the append (a) command.

o i places text to the left of the cursor o a places text to the right of the cursor.

When working with the text of a single line, a caret (,,) moves the cursor to the first nonwhite position on the line, and a

S

moves it to the end of the line. Thus,

Sa

will append new text at the end of the current line. A is equivalent to

Sa.

Ai will insert new text at the beginning of the current line. I is equivalent to Ai.

Many related editor commands are invoked by the same letter key and differ only in that one is given by a lowercase key and the other is given by an uppercase key. The

uppercase key often differs from the lowercase key in its sense of direction (the uppercase key moves backward and/or up, and the lowercase key moves forward and/or down).

It is often the case that you want to add new lines to the file you are editing before or after some specific line in the file.

The 0 command creates a new line after the line you are on, and the 0 command creates a new line before the line you are on. When you create a new line in this way, the text you type is inserted on the new line until you press the GO key.

Whenever you are typing in text, you can give many lines of input or just a few characters. To type in more than one line of text, press the RETURN key at the middle of your input. A new line will be created for text, and you can continue to type. If you are on a slow and dumb terminal, the editor may choose to wait to redraw the tail of the screen and will let you type over the existing screen lines. This avoids the lengthy delay that would occur if the editor attempted to keep the tail of the screen always up to date. The tail of the screen will be fixed and the missing lines will reappear when you press the GO key.

While inserting new text, use the characters normally used at the system command level (usually CODE-h or #) to backspace

over the last character typed; and the character used to kill input lines (usually @, CODE-x, or CODE-u) can be used to erase the input typed on the current line. In fact, CODE-h

(backspace) always erases the last input character regardless of what your erase character is. CODE-w will erase a whole word and leave you aher the space following the previous word. It is useful for quickly backing up in an insert. The following conditions should be noted:

o When you backspace during an insertion, the characters you backspace over are not erased. The cursor moves backward, and the characters remain on the display. This is ohen useful if you are planning to type in something similar. In any case, the characters disappear when you press the GO key. If you want to delete them immediately, press the GO key and then a again.

o You cannot erase characters that you did not insert, and you cannot backspace around the end of a line. If you need to back up to the previous line to make a correction, just press the GO key and move the cursor back to the previous line. Aher making the correction, return to where you were and use the insert or append command again.

Example Three

Start a new file as follows:

$ vi newfilename

At the bottom of the screen, the new file name appears in quotes followed by [New me]. A line of tildes (-) appear on the left side of the screen. The cursor appears on a line above the tildes.

2 Type a lowercase a.

a

Nothing happens. The editor is in the append mode.

3 Type the following paragraph (including errors). Do not worry about making typing mistakes. If your mistakes are too extensive, type :q! and start over. The backspace can be used to type over your errors. Type two spaces

between sentences when the end of the sentence is not at the end of a line:

Wh e n you h a v e sue c e s s f u I I Y log g e din. apr 0 gram called the shell Is listening to your terminal.

The shell read the line you type. splits It Into a command name and Its arguments. and the

command. A simply an executable program.

located In a file. Normally. the shell looks first In your current directory for a program with your directories. There Is nothing special about system-provided commands except that they are kept for the shell to find them there.

4 Press the GO key.

The cursor moves to the left one space. The editor is out of the append mode. The previous steps could have been performed by typing a lowercase i, text, and pressing the GO key.

5 Move the cursor to the third line from the top of the file.

6 Move your cursor to the d in the word "read."

1 Type a lowercase a.

a

The cursor moves one space to the right.

8 Type a lowercase s.

s

The s is added following "read." The remainder of the sentence is moved to the right one space.

9 Press the GO key.

The cursor moves to the left one space. The editor is out of the append mode.

1 0 Move the cursor to the fourth line from the top of the file.

11 Move your cursor to the space following the second "and."

12 Type a lowercase a.

a

The cursor moves one space to the right.

13 Type the following word and then type a space:

executes

The typed information is added following "and. I I The "the"

is moved to the right as you type.

14 Press the GO key.

The cursor moves to the left one space. The editor is out of the append mode.

15 Move the cursor to the fifth line from the top of the file.

16 Move the cursor to the first m in "command."

17 Type a lowercase i.

The cursor remains in the same character space.

18 Type a lowercase o.

o

The 0 is inserted before the first m. The remainder of the sentence moves over one character space.

19 Press the GO key.

The cursor moves to the left one space. The editor is out of the insert mode.

20 Move the cursor to the s in simply.

21 Type a lowercase i.

The cursor remains in the same character space.

22 Type the following text and then type a space:

command is

The typed information is inserted before U simply." The remainder of the sentence moves over as you type.

23 Press the GO key.

The cursor moves to the left one space. The editor is out of the insert mode.

24 Move the cursor to any character in the seventh line from the top of the file.

25 Type a lowercase o.

o

A blank line is added following the line you are on. The cursor appears at the first character space in the empty line.

26 Type the following text:

command name, and if none Is there, then In system

27 Press the GO key.

The cursor moves to the left one space. The editor is out of the open mode.

28 Move the cursor to any character in the last line in your file.

29 Type an uppercase O.

o

A blank line is added preceding the line your cursor is on.

The cursor appears at the first character space in the empty line.

30 Type the following text:

in directories where the shell can find them.

You can (press the RETURN key) also keep commands in your own directories and arrange

31 Press the GO key.

The cursor moves to the left one space. The editor is out of the open mode.

32 Correct your typing errors (if any) where possible, using a, i, 0, and O.

33 The file you have just completed should appear as follows:

When you have successfully logged in, a program called the shell Is listening to your terminal.

The shell reads the I ine you type, spl i ts I t into a command name and its arguments, and executes the command. A command is simply an executable program located In a file. Normally, the shell looks first i n you r cur r e n t d ire c tor y for apr 0 gram wit h you r command name, and If none is there, then in system directories. There is nothing special about system-provided commands except that they are kept In directories where the shell can find them.

You can also keep commands In your own directories and arrange for the shell to find them there.

34 Save this file for use in other examples by typing the following:

zz

At the bottom of the screen, your file name appears in quotes followed by [New file], the number of lines, and the number of characters,

Summary

"w Erases a word during an insert.

erase Erases a character during an insert (usually "h or #).

kill Kills the insert on this line (usually @, "X, or "u).

o

Opens and inputs new line(s) above the current line.

a Appends text after the cursor.

A Appends text after the line on the same line.

Inserts text before the cursor.

Inserts text before the line on the same line.

o Opens and inputs new line(s) below the current line.

Im Dokument XE 500 (Seite 106-112)