Javatpoint Logo
Javatpoint Logo

vi Words

In command mode, you can move one word forward or backward with w and b command respectively.

w

The w command allows us to move one word forward. To move more than one word forward, you can type number before w command.

Example:

9w

Linux Vi Word1

Look at the above snapshot, from the current word we want to move 9 words ahead.

Linux Vi Word2

Look at the above snapshot, we have moved 9 words forward.

Note: Word we'll is counted as three words (we, ' , and ll)

b

The b command allows us to move one word backward. To move more than one word backward, you can type number before b command.

Example:

9b

Linux Vi Word3

Look at the above snapshot, from the current word we want to move 9 words backwards.

Linux Vi Word4

Look at the above snapshot, we have moved 9 words backward.

dw

The dw command is used to delete one word. But remember, to delete one complete word cursor should be placed at the starting letter of the word.

Example 1:

Linux Vi Word5

Look at the above snapshot, we want to delete word example. Our cursor is placed at the starting letter e.

Linux Vi Word6

Look at the above snapshot, after pressing dw command, word example is deleted.

Example 2:

Linux Vi Word7

Look at the above snapshot, here also we want to delete word example. But this time our cursor is placed somewhere at the middle of the word.

Linux Vi Word8

Look at the above snapshot, after pressing dw command, word example is not completely deleted. Only the letters starting from the cursor to the end of the word (including the space) are deleted.

Example 3:

5dw

Linux Vi Word9

Look at the above snapshot, here we want to delete five letters after the current word.

Linux Vi Word10

Look at the above snapshot, after typing 5dw, five words after the cursor are deleted.

yw

The command yw is used to copy one word. Here also cursor has to be placed at the starting to copy a complete word.

Example:

Linux Vi Word11

Look at the above snapshot, we want to copy word example.

Linux Vi Word12

Look at the above snapshot, after pressing yw key, move the cursor at place where you want to copy the word. Here, we have copied it at the last with p command.

Next TopicLinux Searching





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA