vi cut, copy and paste a line in blocks
TIn command mode, if you want to delete, cut or copy n number of lines, just type the number before typing the command. For example, 4dd will delete four number of lines from the current line to the next three lines in downward direction.
In case of yy command, command will be noted by vi. For example, if we have given command 4yy then at the bottom left corner, vi will show a message as "4 lines yanked".
Here n denotes a number. It will delete n number of lines after the current line.
Look at the above snapshot, this is our script and we want to delete first two lines.
Look at the above snapshot, after typing 2dd, two lines after the current lines are deleted.
The command nyy is used to copy n number of lines after the current line.
Look at the above snapshot, we want to copy two lines after the first line.
Look at the above snapshot, after pressing 2yy, last two lines are copied and with P key we have pasted them before the first line.
Next TopicLinux Start and end of a Line