Red HatThis forum is for the discussion of Red Hat Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
hi,
how can i copy and paste selected text from one file to other using vi in RHEL5.i googled and found some methods,like
just use m to mark the start, with an arbitrary buffer name (so you might type mx). Move your cursor down to where you want to stop copying, and type y'x (or d'x if you're cutting and pasting). Then move the cursor to the point where you want to paste, and type p.
when i do this it pastes the entire line of which a part is selected so in essence it is working as yy.
when i open a new file using vi and try to paste it says "nothing in register".what i exactly want to do is copy only the selected text as shown above in red and paste it in a new file.
plz guide
Distribution: Slackware (mainly) and then a lot of others...
Posts: 855
Rep:
I found a way out to deal with this one
You have to open the file in a new tab (esc :newtab) and than press 'p' and it would be pasted.
Hope this works for you too.
when i do this it pastes the entire line of which a part is selected so in essence it is working as yy.
To copy part of a line you can simply use the y (yank) command:
Code:
yw copies a single word
yNw where N is a number copies N words
ye avoids copying the blank space after the word
yNe same as above for multiple words
y$ copies form the cursor position to the end of the line
To paste it into another file, you can copy the text, then edit another file inside the same vi session using the edit command
I forgot to mention that you can copy/paste any portion of text by entering in Visual Mode. Just press v to switch to visual, then move the cursor using the arrows keys to select text, then use y and p to copy and paste respectively.
According to Hewlett Packard's excellent "The Ultimate Guide to the vi and ex Text Editors", the ʾ is used for marking lines and the ʻ for marking character positions. In case you can't see the difference the first is a closing single quote and the second an opening single quote, the characters that are sometimes known as "smart single quotes" in word-processing, hex codes 02BE and 02BB.
That's not much use on IBM-PC style keyboards which have neither. The ' character which they do have is treated as the closing single quote so is a line marker as described earlier.
If using a terminal with copy and paste facilities the text can be copied and pasted, the pasting working as if the text were typed so best to be in input mode! The copy will also copy line numbers if displayed so :se nu! is useful.
Vim is hugely configurable so it may be possible to redfine some other character to be equivalent to the opening single quote.
Last edited by catkin; 11-20-2010 at 05:59 AM.
Reason: subediting
I forgot to mention that you can copy/paste any portion of text by entering in Visual Mode. Just press v to switch to visual, then move the cursor using the arrows keys to select text, then use y and p to copy and paste respectively.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.