• Keine Ergebnisse gefunden

Miscellaneous Movement Features

Im Dokument XE 500 (Seite 91-106)

The command G, preceded by a number, will position the cursor at that line in the file. Thus 1 G will move the cursor to the first line of the file. If you give G no count, the cursor moves to the end of the file.

You can also get back to a previous position by using the command \\ (two grave accents). This is often more convenient than G because it requires no advance

preparation. If you accidentally enter n or any command that moves you far away from a context of interest, you can quickly get back by typing "

Example Two

Note: This example does not use the RETURN key to end command lines unless specified in the instructions.

I Window movements.

Scrolling.

a Make a copy of a familiar file.

b To access the file copy, enter the vi command and the name of your file followed by pressing the RETURN key:

$ v I f I len ame

The file name will appear in quotes at the bottom of the screen. The first part of the file will then appear on the screen. The cursor will be at the top left character in the file. The file name, number of lines, and number of characters will be displayed on the bottom of the screen.

c Press the CODE key and the D key at the same time.

CODE- d .

The cursor is advanced down in the file. (The screen scrolls up adding some new lines at the bottom of the screen.) (For most terminals, eight is a default number of lines; your terminal may scroll more or fewer lines.)

d Press the CODE key and the U key at the same time.

CODE-u

The screen scrolls down, and the cursor is back at the beginning of the file.

When entering a number with CODE-d or CODE-u, the number of lines requested last is the permanent amount scrolled when next the CODE-d or CODE-u is entered without a number.

e Press the CODE key and the E key at the same time.

CODE-e

One more line is exposed at the bottom of the screen.

The cursor remains on the same line.

f Press the CODE key and the Y key at the same time.

CODE-y

One additional line scrolls on to the top of the screen.

The cursor remains on the same line.

2 Paging.

a Press the CODE key and the F key at the same time.

CODE-f

The screen goes blank momentarily. A new screen image appears containing the last couple of lines of the previous screen image at the top of the screen.

These lines are followed by new lines forward in the file. The cursor is at the top of the screen.

b Press the CODE key and the B key at the same time.

CODE-b

The screen goes blank momentarily. A new screen image appears containing the first couple of lines of the previous screen image at the bottom of the screen. These lines are preceded by new lines backward in the file. The cursor is at the bottom of the screen.

c Practice paging forward and backward in the file. (A number may be entered preceding the input of CODE-f or CODE-b. The number indicates the number of screen fulls to move forward or backward. It is difficult to keep up with your position in the file when paging more than one screen full.)

II Cursor movements.

1 Cursor positioning keys.

If your terminal has cursor positioning (arrow) keys, perform the following:

a Move the cursor to the right to the end of a line and back with the left and right cursor positioning keys.

b Move the cursor to the bottom of the screen with the down cursor positioning key.

c Add lines to the bottom of the screen with the down cursor positioning key.

d Move the cursor to the top of the screen with the up cursor positioning key.

e Add lines to the top of the screen with the up cursor positioning key.

f Move the cursor to the right 20 character spaces by typing 20 and pressing the right cursor key.

20rlght cursor key

If there are less than 20 characters on the line, the cursor will stop on the last character in the line.

9 Move the cursor to the left ten character spaces by typing 1 0 and pressing the left cursor key.

10left cursor key

If there are less characters to the left of the cursor than ten, the cursor will stop on the first character in the line.

h Move the cursor down ten lines in the file by typing 10 and pressing the down cursor key.

10down cursor key

The cursor moves down ten lines. The cursor remains ten characters to the left. If the line is less than ten characters long, the cursor is on the last character on the line.

Move the cursor down 15 more lines.

15down cursor key

The screen scrolls up and the cursor remains ten characters to the left on the bottom line. If the line is less than ten characters long, the cursor is on the last character on the line.

j Move the cursor up 12 lines by typing a 1 2 and pressing the up cursor key.

12up cursor key

The cursor moves up 12 lines.

k Move the cursor up 13 lines.

13up cursor key

The screen scrolls down and the cursor has returned to its position prior to moving down 25 lines.

2 h, j, k, and I

a Move the cursor to the right to the end of a line with lowercase I's and back with lowercase h's. (This performs the same function as the cursor right and left keys.)

b Move the cursor to the bottom of the screen with lowercase j's.

c Add lines to the bottom of the screen with lowercase j's.

d Move the cursor to the top of the screen with lowercase k's.

e Add lines to the top of the screen with lowercase k's.

f Move the cursor to the right 20 character spaces by typing 20 and lowercase I.

201

If there are less than 20 characters on the line, the cursor will stop on the last character in the line.

9 Move the cursor to the left ten character spaces by typing 10 and a lowercase h.

10h

If there are less characters to the left of the cursor than ten, the cursor will stop on the first characte~ in the line.

h Move the cursor down ten lines in the file by typing 10 and a lowercase j.

10 j

The cursor moves down ten lines. The cursor remains ten characters to the left. If the line is less than ten characters long, the cursor is on the last character on the line.

i Move the cursor down 15 more lines.

15 j

The screen scrolls up and the cursor remains ten characters to the left on the bottom line. If the line is less than ten characters long, the cursor is on the last character on the line.

j Move the cursor up 1 2 lines by typing a 12 and a lowercase k.

12k

The cursor moves up 12 lines.

k Move the cursor up 13 lines.

13k

The screen scrolls down and the cursor has returned to its position prior to moving down 25 lines.

3 BACKSPACE, RETURN,

+, .,

and SPACEBAR.

a Move the cursor to the right to the end of a line with the SPACEBAR and back with the BACKSPACE key (CODE-h will also work).

b Move the cursor to the bottom of the screen with the RETURN key. (The

+

key will also do this.)

c Add lines to the bottom of the screen with the RETURN key.

d Move the cursor to the top of the screen with the - key.

e Add lines to the top of the screen with the - key.

f Move the cursor to the right 20 character spaces by typing 20 and pressing the SPACEBAR.

20

If there are less than 20 characters on the line, the cursor will stop on the last character in the line.

9 Move the cursor to the left ten character spaces by typing 10 and pressing the BACKSPACE key.

10

If there are less characters to the left of the cursor than ten, the cursor will stop on the first character in the line.

h Move the cursor down ten lines in the file by typing 10 and pressing the RETURN key.

10

The cursor moves down ten lines. The cursor moves to the first character space on the line. (The

+

key will perform the same operation.)

i Move the cursor down 15 more lines.

15

The screen scrolls up and the cursor moves down 1 5 lines. The cursor remains in the first character space on the line.

j Move the cursor up 1 2 lines by typing a 12 and pressing the hyphen (-) key.

12-The cursor moves up 12 lines.

k Move the cursor up 13 lines.

13

-The screen scrolls down. -The cursor has returned to its position prior to moving down 25 lines except the cursor has moved to the first character space on the line.

III Moving by objects.

Moving by characters.

a Place the cursor at the beginning of a long line containing a large number of entries of the same character. (The cursor does not have to be on the first character.)

b Type a lowercase f and a.

fa

The cursor moves to the right to the first" a" on the line.

c Type a semicolon.

The cursor moves to the right to the next Ha" on the line.

d Continue to type semicolons until the last a on the line is reached.

After reaching the last a on the line, typing more semicolons will not move the cursor any further.

e Type a comma.

The cursor moves back to the next to last a on the line.

f Move the cursor to the end of the line. (The cursor does not have to be on the last character on the line.) 9 Type an uppercase F and a lowercase character that

appears several times on the line, for example an e.

Fe

The cursor moves to the left to the next" e" on the line.

h Type a semicolon.

The cursor moves to the left to the next "e" on the line.

i Continue to type semicolons until the first "e" on the line is reached.

After reaching the first "e" on the line, typing more semicolons will not move the cursor any further on the line.

j Type a comma.

The cursor moves to the right to the second "e" on the line.

k Move the cursor to the beginning of the line.

I Type a 3 followed by a lowercase f and a. (This step assumes there are at least three a's on your test line.)

3f8

The cursor moves to the right to the third a on the line.

m Type a 2 followed by a semicolon. (This step assumes there are at least five" a'" s on your test line.)

2;

The cursor moves to the right two more "a'''s.

n Type a 4 followed by a comma.

4.

The cursor moves to the left four "a'''s.

o

Move backward on the line searching for a character using numbers, F's, semicolons, and commas.

The cursor moves as in the previous three steps except in the opposite direction.

p Practice moving the cursor to desired characters by using f' 5, F's, numbers, semicolons, and commas.

q Perform the steps just performed for moving to characters except subtitute a t for the f and a T for the F.

When typing the t, the cursor in each step will move to the character to the left of the character being searched for. When typing the T, the cursor in each step will move to the character to the right of the character being searched for.

2 Moving by words.

a Type an uppercase W.

w

The cursor moves to the right to the first character in the next word on the line. If the cursor is on any character in the last word in the line, the cursor will move to the first character in the first word in the next line down.

b Type a lowercase w.

w

The cursor moves as before except the cursor stops at punctuation and other non-alphabetical and non-numerical characters.

c Type an uppercase B.

B

The cursor moves to the left to the first character in the next word in the line. If the cursor is on any character in the first word in the line, the cursor will move to the first character in the last word in the next line up.

d Type a lowercase b.

b

The cursor moves as before except the cursor stops at punctuation and other non-alphabetical and non-numerical characters.

e Type an uppercase E.

E

The cursor moves to the right to the last character in the current word. If the cursor is on the last character in a word, the cursor will move to the last character in the next word to the right. If the cursor is on the last character of the last word in a line, the cursor will move to the last character of the first word on the next line down.

f Type a lowercase e.

e

The cursor moves as before except the cursor stops at punctuation and other non-alphabetical and non-numerical characters.

9 Type a 5 and an uppercase W.

5W

The cursor moves to the right to the first character of the fifth word. The cursor will move down to the next line(s) if five remaining words are not in the current line.

3 Moving by sentences. The following feature of the vi editor will work only if two spaces are used between the end of sentence punctuation and the beginning of the next sentence.

a Place the cursor at the beginning of a paragraph.

b Enter a right parenthesis.

The cursor moves down to the first character of the next sentence.

c Enter a left parenthesis.

The cursor moves up to the first character of the previous sentence.

d Type a 4 and a right parenthesis.

4 )

The cursor moves down in your file to the first character of the fifth sentence.

e Type a 3 and a left parenthesis.

3(

The cursor moves up in your file to the first character of the second sentence in the paragraph.

f Move the cursor to a sentence in the next paragraph by typing single right parenthesis in succession.

The cursor stops at the beginning of an empty space.

The space between paragraphs counts as one sentence.

9 Practice moving the cursor by typing numbers, right parentheses, and left parentheses.

4 Moving by paragraphs.

a Move the cursor to the beginning of your file by using any of the following:

CODE-u CODE-b

up cursor key k

b Type a right brace.

}

The cursor moves down to the beginning of the next empty line.

c Type a left brace.

{

The cursor moves up to the beginning of the first line in your file.

d Type a 3 and a right brace.

3)

The cursor moves down to the third empty line space in your file.

e Type a 2 and a left brace.

2{

The cursor moves up to the first empty line space in your file.

f Practice moving by paragraphs using numbers, left braces, and right braces.

5 Moving to the beginning and ending of lines.

a Place the cursor in the middle of a line.

b Type a zero.

o

The cursor moves to the first character space on the current line.

c Type a dollar sign.

$

The cursor moves to the last character in the current line.

d Move the cursor back to the middle of the line.

e Type a 2 and a dollar sign.

2$

The cursor moves to the last character of the next line. When using numbers and $'s, the line count includes the current line.

IV Moving by matching character strings.

Move the cursor to the first line in your file.

2 Select a word to "search for" that appears on the screen.

3 Type a forward slash.

The slash appears at the bottom left of the screen.

4 Type your word and press the RETURN key.

word

Your word follows the slash at the bottom of the screen. After pressing the RETURN key, the cursor moves to the first character of the first appearance of your word on the screen.

S Find the next occurrence of your word by typing an n.

n

A forward slash appears at the bottom of the screen.

The cursor moves forward in your file to the first character in the next appearance of your word.

6 Move the cursor to the bottom line of the screen.

7 Select another word to search for that appears on the screen.

8 Perform a backward search by typing the following:

?word2

Your second word follows the question mark at the bottom of the screen. After pressing the RETURN key, the cursor moves to the first character of the first appearance of your word in a backward direction in your file.

9 Find the next occurrence of your word by typing an n.

n

A backward slash appears at the bottom of the screen. The cursor moves backward in your file to the first character in the next appearance of your word.

10 Type an uppercase N.

N

A forward slash appears at the bottom of the screen.

The cursor moves forward in your file to the first character of your word2 (back to the same word in the previous step). (A forward slash and pressing the RETURN key will also reverse the direction of the search.) 11 Select a word in your file that is the first word on a line.

12 Move the cursor to a position in your file ahead of the word.

13 Type a forward slash, a caret, and your third word, followed by pressing the RETURN key.

/"word3

The information typed appears at the bottom of the screen . After pressing the RETURN key, the cursor moves forward to the next appearance of your word at the beginning of the line.

14 Select a word in your file that is the last word on a line.

15 Move the cursor to a position in your file ahead of the word.

16 Type a forward slash, your fourth word, and a dollar sign followed by pressing the RETURN key.

/ word4$

16 The information typed appears at the bottom of the screen . After pressing the RETURN key, the cursor moves forward to the next appearance of your word at the end of a line.

17 Type a forward slash followed by a word that you know is not in your file. Press the RETURN key.

/word5

At the bottom of the screen the following message appears:

IPattern not found

The word initially searched for does not have to appear on the screen.

String searches normally search to the end or beginning of the file and continue searching from the opposite end of your file until your word is found.

Summary

Searches forward for a character string.

Searches backward for a character string.

Moves cursor backward a word ignoring punctuation.

Moves cursor to specified line or to last line if default.

Moves cursor forward a word ignoring punctuation.

Moves cursor backward a word.

Moves cursor to end of current word.

Moves cursor to the left.

Moves cursor down (in same column).

Moves cursor up (in same column).

n w

Moves cursor to the right.

Repeats scan for next instance of / or ? pattern.

Moves cursor forward a word.

Im Dokument XE 500 (Seite 91-106)