Javatpoint Logo
Javatpoint Logo

vi Join two lines and more

In command mode, two lines can be joined, switched and repeated.

J

The J command can be used to join two lines.

Example:

Linux Vi Join1

Look at the above snapshot, we need to join first two lines of the above script.

Linux Vi Join2

Look at the above snapshot, after pressing J, both the lines are joined.

yyp

The yyp command repeat the current line.

Example:

Linux Vi Join3

Look at the above snapshot, our current line is the second line.

Linux Vi Join4

Look at the above snapshot, after pressing yyp command, current line is repeated.

ddp

The command ddp swaps two lines (current line and line below the current line).

Example:

Linux Vi Join5

Look at the above snapshot, last two lines are swapped from their positions.

Next TopicLinux vi Words




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


B.Tech / MCA