vi editor-how to copy & paste - Questions

This is a discussion on vi editor-how to copy & paste - Questions ; How can we copy a block of statements and paste those statements in VI editor in Unix/Linux. If anybody knows the answer, kindly reply me with the answer. My e-mail ID:saravananblore@yahoo.co.in Thank u all....

+ Reply to Thread
Results 1 to 3 of 3

Thread: vi editor-how to copy & paste

  1. vi editor-how to copy & paste

    How can we copy a block of statements and paste those statements in VI
    editor in Unix/Linux.

    If anybody knows the answer, kindly reply me with the answer.

    My e-mail ID:saravananblore@yahoo.co.in

    Thank u all.

  2. Re: vi editor-how to copy & paste

    saravananblore@yahoo.co.in said the following, on 08/18/04 04:24:
    > How can we copy a block of statements and paste those statements in VI
    > editor in Unix/Linux.
    >
    > If anybody knows the answer, kindly reply me with the answer.
    >
    > My e-mail ID:saravananblore@yahoo.co.in
    >
    > Thank u all.


    To copy a group of 'n' consecutive lines, use 'yy' and 'p'.

    For example, to copy 4 lines (in command mode):

    1. Move the cursor to the first line to be copied.
    2. '4yy'
    3. Move cursor to the destination.
    4. 'p'

    (Things in quotes are vi commands.)



    --
    Rich Gibbs
    rgibbs@alumni.princeton.edu

  3. Re: vi editor-how to copy & paste

    >
    > 1. Move the cursor to the first line to be copied.
    > 2. '4yy'
    > 3. Move cursor to the destination.
    > 4. 'p'
    >

    "man vi" will do you more good than reading these emails...

    You could also:

    1. Move to the first line of text to be copied.
    2. Hit ctrl-G and note which line # you are on.
    3. Move to the last line of text to be copied.
    4. Hit ctrl-G and note which line # you are on.
    5. Type ":[start line],[last line]y" then Return.
    6. See steps 3 and 4, above.

    You could also put the text into a named register for transfer to another vi
    session, etc. by using:

    :"a30y

    which would yank 30 lines and put them into register "a". Note the
    double-quote preceding the \a\... it denotes a register.



+ Reply to Thread