vi Start and End of a line

In command mode, 0 and caret ^ sign will bring you at the start of the current line while $ sign will bring you at the end of the current line.

These signs can be added to another command to perform certain functions. For example, d0 will delete characters between current character and start of the line. And d$ will delete characters between current character and end of the line.

0

The 0 sign bring you to the start of the current line.

Example:

Linux Start and end1

Look at the above snapshot, currently our cursor is at the middle of the second line.

Linux Start and end2

Look at the above snapshot, after pressing key 0, we're at the starting of second line.

^

The ^ sign also bring you at the start of the current line.

$

The $ sign will bring you to the end of the current line.

Example:

Linux Start and end3

Look at the above snapshot, currently our cursor is at the middle of the second line.

Linux Start and end4

Look at the above snapshot, after pressing $ key, we are at the end of the current line.

d0

Combining sign 0 with d command enables us to delete start of a line from current character.

Example:

Linux Start and end5

Look at the above snapshot, position of the cursor is somewhere in the middle of the line.

Linux Start and end6

Look at the above snapshot, letters from starting to the current character are deleted.

d$

Combining sign $ with d command enables us to delete from current character to the end of the line.

Example:

Linux Start and end7

Look at the above snapshot, position of the cursor is somewhere in the middle of the line.

Linux Start and end8

Look at the above snapshot, letters from current character to the end of the line are deleted.

Next TopicLinux vi Join




Latest Courses