vi cut, copy and paste (Line)In command mode, you can cut, copy and paste a line with the following commands. cut dd The command dd deletes current line completely. Example: ![]() Look at the above snapshot, our cursor is at line third. We want to delete this whole line. ![]() Look at the above snapshot, after pressing dd command, third line is deleted. copy yy The command yy (yank yank) is used to copy a line. Move the cursor to the line you want to copy and then press yy. paste p The p command paste a copied or cut content after the current line. Example: ![]() Look at the above snapshot, this is our original script. ![]() Look at the above snapshot, first we have copied the second line using yy, then press p. Copied line will paste after the current line. P The P command paste a copied or cut content before the current line. Example: ![]() Look at the above snapshot, this is our original script. ![]() Look at the above snapshot, after copying the content using yy, we moved the cursor to first line and then pressed P. Line is copied before the current line. |