home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / question / 10603 < prev    next >
Encoding:
Internet Message Format  |  1992-08-31  |  3.8 KB

  1. Path: sparky!uunet!oracle!pyramid!pyramid.COM!kathyj
  2. From: kathyj@pyramid.COM (Kathy Johnson )
  3. Newsgroups: comp.unix.questions
  4. Subject: Re: vi (cut and paste)
  5. Keywords: vi
  6. Message-ID: <183333@pyramid.pyramid.com>
  7. Date: 31 Aug 92 20:04:21 GMT
  8. References: <1992Aug17.200149.7817@s912%bnf.com> <515@alden.UUCP> <17bsqjINNgn6@darkstar.UCSC.EDU> <1992Aug25.035349.6759@uxa.ecn.bgu.edu>
  9. Sender: news@pyramid.pyramid.com
  10. Distribution: usa
  11. Organization: Pyramid Technology Corporation, Mountain View, California
  12. Lines: 90
  13.  
  14. In article <1992Aug25.035349.6759@uxa.ecn.bgu.edu>, mflll@uxa.ecn.bgu.edu (Dr. Laurence Leff) writes:
  15. |> I have prepared some Helpful Hint files on common problems of moving
  16. |> text around from file to file or within a file.  Perhaps, they may  
  17. |> be helpful.  Thus, I post the three files here.  Enjoy.
  18. |> 
  19. |> These were posted and made available on this machine for all to use.
  20. |> 
  21. |> 
  22. |> Dr. Laurence Leff  Western Illinois University, Macomb IL 61455 ||(309) 298-1315
  23. |> Stipes 447 Assistant Prof. of Computer Science ||Pager: 837-5909 FAX: 298-2302
  24. |> Moderator:  Symbolic Math List, Technical Reports List||mflll@uxa.ecn.bgu.edu 
  25. |> alt.binaries.pictures.fine-art hierarchy          ||BITNET: mflll@ecnuxa.bitnet
  26. |> ______________________________________________________________________
  27. |>             How to Move Text from One File to Another in VI
  28. |> 
  29. |> Frequently, a question arises, how do I move a block of text from
  30. |> file1 to somewhere  within file2.  This note will give you one way
  31. |> of performing this task using the vi editor.
  32. |> 
  33. |> For example, you may have a procedure defined in file1 and you would
  34. |> like to make use of it in a program contained in file2.
  35. |> 
  36. |> file1 and file2 refer to arbitrary file names.  Substitute the names
  37. |> of the source file containing the text you want to copy for "file1"
  38. |> in the instructions below and the name of the target file where
  39. |> you want to copy the stuff into "file2"
  40. |> 
  41. |> This will consist of starting file1 up with vi, copying the block
  42. |> of text to a temporary file.  Then you will read the temporary file
  43. |> into the appropriate location in file2.
  44. |> 
  45. |> 1. Get into file1 by typing "vi file1"
  46. |> 
  47. |> 2. Move the cursor to the first line in the region to be copied.
  48. |> 
  49. |> 3. Press "ma"
  50. |> 
  51. |> 4. Move the cursor to the last line (bottom line) of the region to
  52. |>    be copied.
  53. |> 
  54. |> 5. Type the following sequence of characters
  55. |>    :'a,.w /tmp/xxx
  56. |> 
  57. |>    You may use any name you want instead of xxx
  58. |> 
  59. |>     The machine will display a message at bottom of screen beginning
  60. |>     with "/tmp/xxx" [New file]
  61. |>    and then tell you how many lines and chars you put in this temporary
  62. |>     file.
  63. |> 
  64. |> 6. Leave vi.  You can use the sequence ":wq" for this purpose.
  65. |> 
  66. |> 7. Now get into file2 by typing "vi file2"
  67. |> 
  68. |> 8. Move the cursor to the line just before you want to add the
  69. |>    text
  70. |> 
  71. |> 9. Type the following sequence of characters
  72. |>    :r/tmp/xxx
  73. |> 
  74. |> All done!
  75. |>
  76. Here is a quicker way to move a block of text from file1 to file2:
  77.  
  78. 1.  Get into file1 by typing "vi file1"
  79. 2.  Move the cursor to the first line in the region to be copied.
  80. 3.  Press "ma"
  81. 4.  Move the cursor to the last line (bottom line) of the region to be copied.
  82. 5.  Type the following sequence of characters
  83.     "By'ay
  84.      You may substitute another letter for the buffer name  (B in the sample)
  85. 6.  Do not exit vi.  Open the other file by typing the following sequence of
  86.     characters:
  87.     :e file2
  88. 7.  Move the cursor to the line you wish to place the text AFTER.
  89. 8.  Type the following sequence of characters:
  90.     "Bp
  91.     If you used a different buffer name replace B with the buffer name you used.
  92.  
  93. It's only a little shorter but saves going in and out of vi.
  94.  
  95. Have fun,
  96.  
  97. Kathy Johnson
  98.  
  99. -- 
  100. Lost:  One clever .sig file.  Short, witty and sweet.  Reward.
  101.        Does not bite.
  102.  
  103.        kathyj@pyramid.
  104.