Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2007
    Posts
    59

    Unanswered: How to copy data in VI editor

    Hi
    I am new to shell scripting and vi editor.
    I have 2 file and I want to copy some selected data from first file to other.

    How can I do this ??


    Thanks in advance


    Regards

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Code:
    vi first  edit source file
    then move your cursor to start of selection
    'ma       mark current position with letter a
    then move your cursor to end of selection
    "xy'a     yank to buffer x from current position to mark a
    :e other  edit target file
    move cursor to where you want the data
    "xp       put from buffer x

  3. #3
    Join Date
    Aug 2007
    Posts
    59
    Hi thnks for reply.

    when i tried to give : 'ma

    it show the mesage : E20: Mark not set.

    but i used :r filename. It paste all the data from file2 to file1

    After that I edited the file1. Problem solved.

    But if the file2 is very big then it is not always possible to use :r method.

    Pl reply how to use 'ma method..


    Thanks and Regards

  4. #4
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Note:
    NO : before 'ma
    and I use :e not :r

  5. #5
    Join Date
    Aug 2007
    Posts
    59
    hi my file1 is like this:
    PATH=......
    SHELL=/bin/sh
    USER=sa
    LOGNAME=sybase
    for i ........

    then i use 'ma ( i think this is start of mark )
    then my file will be (Vi in insert mode ):

    PATH=......
    'ma
    SHELL=/bin/sh
    USER=sa
    LOGNAME=sybase
    "xy'a
    for i ........

    is this code is right?? if it is,

    Then i used :e file2

    It gives the message as
    E37: No write since last change ( add ! to override )

    Pl reply


    Thanks and regards

  6. #6
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    No, don't insert it as text (don't modify file1)
    You should not be in insert mode when entering the commands 'ma etc.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •