29

Dec 08

Copying a block of text from one file to another in Vi

To copy a block of text between files execute the commands:

Command Explaination
1. Edit the file containing the text you want to copy.
2. Go to the top line to be copied.
3. ma Mark this line as mark “a”.
4. Go to the bottom line to be copied
5. y'a Yank (y) the text from the current cursor location to the mark “a” ('a)
6. :split second-file Open another window containing the second file. (This the file in which the text is to be inserted.)
7. Go to the line where the insert is to occur. The text will be place after this line.
8. p Put the text after the cursor.

No comments yet, be the first.

Leave a Reply