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. You can also go to a specific line in the file by entering the number of the line that you want, followed by g+g. For example, 15 g+g would take you to line 15 of the file that you are editing.

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 line, " to move to the beginning of the line, 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 operation affects the cursor.

Starting at the end of line 1

This

is

hie

1

This

is

inc

2

This

is

nitr

3

This

IS

inn

4

This

is

1 Uli

b

This

Es

inn

ft

This

is

inc

7

This

IR

inn

fi

This

is

inc

This

is

Hie

Using Shift+g to move to the end of the file

This

is

intr

i

This

IS

inc

2

This

is

nitr

3

This

IS

inr

4

This

IS

i in:

b

This

Es

Inc

ft

This

is

inc

7

This

Is

inn

fi

This

is

inc

This

is

me

ID

To move to the start of the current line, you can also use the zero (0) key or the Home key.

- r ■ rj All of the keys on the Insert/Delete/Home/End/PageUp/PageDown keypad perform

■i-'j ^ .■¿•CV-.wthe actions you'd expect in vim.

Was this article helpful?

0 0

Post a comment