Attila Bukta, PhD
Home > Linux > Copying a block of text from one file to another in Vi

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

December 29th, 2008 Leave a comment Go to comments

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.
  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.