Moving around the text

We have talked about using the cursor to move around the text while in command mode. To speed up your text editing, you can use shortcuts to move quickly to blocks of text, the start and end of a file, and to the start and end of a line of text.

Moving to the start and end of a file

To move to the end of a file (and this applies to quite a few text-based applications in Linux such as man and less), press Shift+g. To move to the start of the file, press g+g.

Moving around a line of text

To move around a line of text, you can use w to move to the next word, $ to move to the end of the file, and Shift+a to move the cursor to the end of the line and enter append mode.

It is very useful to combine the end-of-line operation with the append operation to add text to the end of the line.

Figures 11-2 and 11-3 demonstrate this. Keep an eye on the location coordinates at the bottom-right corner of the screen to see how the Shift+g and Shift+a operations affect the cursor.

Dits fs line 1

Diis is lime Z

Diis is line 3

riiis is lime 4

TJiis fs Iine 5

rjiis is line 7

Tliis is 1 i ne G

rilis is I ine 9

Ihis is lire 10

Figure 11-2: Starting at the end of line one

riiis

is

lime

i

rjiis

is

line

Z

rjiis

is

1 Ira

3

riiis

is

lime

■i

rjiis

is

lliHe

5

rjiis

is

line

6

riiis

is

1 ine

7

riiis

13

i ine

B

riiis

is

I ine

9

rjiis

is

I ine

IB

Figure 11-3: Using Shift+g and Shift+a to move to the end of the file

To move to the start of the current line, use the zero (0) key.

Was this article helpful?

0 0

Post a comment