Advertisement
BigOncleSam

VI COPY LINES

Nov 6th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 1.16 KB | None | 0 0
  1. VI COPING BETWEEN FILES
  2.  
  3. VI editor is a very powerful editor.
  4. Suppose you want to copy
  5. line numbers 1-10 and 23-77 of
  6. file A and paste them on file B at
  7. the same time, what will
  8. you do ?? Here I am giving a tip
  9. to do this :-
  10.  
  11. Place the cursor on line no. 1
  12. Press ESCAPE
  13. Press Shift "(Shift double quotes)
  14. Press a
  15. Press 10yy [the number of lines you
  16. want to copy]
  17.  
  18. Now place the cursor on line no. 23
  19. Press ESCAPE
  20. Press Shift "(Shift double quotes)
  21. Press b
  22. Press 55yy [the number of lines you
  23. want to copy]
  24.  
  25. Now the first 10 lines have been
  26. copied in buffer "a" and next
  27. 55 lines have been copied in
  28. buffer "b".
  29.  
  30. Now press " : " (COLON) to get
  31. the vi prompt.
  32. Hit e "Destination file name"
  33.  
  34. Once you enter the Destination file
  35. go to the line where you
  36. want the first 10 lines in buffer
  37. "a" to be inserted.
  38.  
  39. Press ESCAPE.
  40. Press Shift "(Shift double quotes)
  41. Press a.
  42. Press p.
  43.  
  44. The first 10 lines in buffer "a"
  45. gets inserted.
  46.  
  47. Now go to the line where you want the
  48. rest 55 lines in buffer
  49. "b" to be inserted.
  50.  
  51. Press ESCAPE.
  52. Press Shift "(Shift double quotes)
  53. Press b.
  54. Press p.
  55.  
  56. The rest 55 lines in buffer "b"
  57. gets inserted.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement