Linux Tips and Stuff



Google
 


Thursday, March 30, 2006

VI COPY FILE TO FILE

VI COPY FILE TO FILE

Here is how to copy the required number
of lines from one file to another in
VI editor. First use the following
key combinations in the source file.

Press ESCAPE
Press Shift "(Shift double quotes)
Press a
Press the number of lines you want to copy
press y followed by another y

Now press " : " (COLON) to get the vi prompt.
Hit e "Destination file name"
Once you enter the Destination file
go to the line where you want the lines
copied to be inserted.

Press ESCAPE.
Press SHIFT "(Double quotes).
Press a.
Press p.

The lines get copied.

4 Comments:

  • really helpful

    thanx :)

    By Blogger Amit, at 9:30 PM  

  • beautiful! This just saved me a TON of aggravation!

    j

    By Blogger j, at 1:38 AM  

  • Or do

    ESCAPE
    v
    (select the block you want to operate on)
    y
    : e [file name]
    (go to the position you want to copy to)
    p


    This is done in Visual mode and saves you counting lines and allows you to select block gedit style.

    By Blogger Tejas, at 5:05 AM  

  • very cool

    By Blogger Amarnath, at 7:32 PM  

Post a Comment

<< Home