Inquiry:How to copy/paste in vi text editor
Dear All
Can you please do me favor and let me know how can I copy lengthy strings from one text file and paste it into another text file in vi text editor ? Regards H.Motamedi |
vi both files by giving both as arguments on the command line. At first use :n to go to the next file then use :# to switch between files. Go to the file you want to copy text from. Name a buffer with "a (the a can be any letter). Copy stuff into the buffer in the normal way, maybe yy, 5yy, y5G whatever. Use :# to switch to the other file. Nominate the same buffer with "a and then put in the normal way, maype p, P whatever.
|
Here comes a step-by-step guide:
1. Edit the file from which you want to copy text 2. Put the cursor onto the upper line to be copied 3. Mark this line (press ma in sequence) 4. Go to the lower line to be copied 5. Pull the text from the current location to the line marked with a (press y'a in sequence) 6. Open the file to paste the text into in the same terminal using the vi command :split filename 7. Go to the line where the insertion is needed 8. Paste the text after the cursor (press p) 9. Save and quit. Hope this helps! :) |
Another way (using visual mode):
1. Edit the file from which you want to copy text 2. Put the cursor onto the upper line to be copied 3. Switch to visual mode (press uppercase V). The line will be highlighted. 4. Go to the lower line to be copied. All the text between the two lines will be highlighted. 5. Yank the text (press y) 6. Open the file to paste the text into in the same terminal using the vi command :split filename 7. Go to the line where the insertion is needed 8. Paste the text after the cursor (press p) 9. Save and quit. |
Hello Colucix :) :split's nice; how do you jump from file to file on screen?
|
Quote:
|
Quote:
|
I usually just highlight src with the mouse, then 'i' insert mode on in target file and mouse-paste.
For large inserts, get the src txt into a file, then in the target file, move the cursor to where you need the insert, then :r srcfile to insert. |
All times are GMT -5. The time now is 07:48 PM. |