Lets say you have a file named file1.txt
You can enable the line number (as example above) by using the command “:set nu” in vi’s command mode. first we need to do copy paragraph 1. Press Esc to make sure you’re in the command mode, then position your cursor at line 1 (column is not important as you’ll copy the whole line anyway), and type:
mk
Then move your cursor to line 4 and type:
“ay’k
If successful, the cursor will move automatically to line 1 (where you do the mk earlier).
The Explanation: mk is to mark the beginning text block that you want to copy, and the “ay’k is to mark the end of the text block. The a is the buffer tag, you can store another text block into another buffer for example buffer b, or c or so on. Now lets continue our example.
Still in VI’s command mode, type : (colon) (the cursor will move to the bottom-left of the screen) and followed by e file2.txt as shown below, and then press ‘Enter’ key.
This will open file2.txt. Then press ‘ap’ to paste the content from the ‘a’ buffer to the file.