LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-19-2009, 03:37 AM   #1
hadimotamedi
Member
 
Registered: Aug 2009
Posts: 228

Rep: Reputation: 30
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 some text in one file and paste it to another file ,when both of the files are being opened by vi text editor ?
Thank you in advance
 
Old 09-19-2009, 03:51 AM   #2
j_jerry
Member
 
Registered: Sep 2009
Distribution: fedora 11
Posts: 318

Rep: Reputation: 46
To copy the current line use yy , copy a word yw , copy 4 words y4w like that

to paste what you've copied use p or P
 
Old 09-19-2009, 04:29 AM   #3
hadimotamedi
Member
 
Registered: Aug 2009
Posts: 228

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by j_jerry View Post
To copy the current line use yy , copy a word yw , copy 4 words y4w like that

to paste what you've copied use p or P
Thank you very much for your reply . But I meant copy from one file and paste to the other file , that both of the files are being opened concurrently in separate vi sessions . Can you please do me favor and modify your proposed procedure to get through ?
Thank you in advance
 
Old 09-19-2009, 04:29 AM   #4
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by j_jerry View Post
To copy the current line use yy , copy a word yw , copy 4 words y4w like that

to paste what you've copied use p or P
Translated, this means that, unless you are either a masochist or a computer software historian, you should choose a modern text editor.

I can use an abacus that is ingeniously connected to a computer, but I would prefer to use something a bit more up-to-date. By the same reasoning I would prefer any editor -- any editor -- over vi. My antique program Apple Writer, which ran on the Apple II and was terribly limited by modern standards, easily outperformed vi.

There are dozens of programs more usable than vi, whose command set was originally designed to avoid an unnecessary waste of paper at a time when all computer transactions were conducted on a paper teletype terminal, at great cost and expenditure of time. (I was obliged to use vi while working on the NASA Space Shuttle in the early 1970s.)

The appearance of the first glass terminal ought to have marked the end of vi's useful life, but no ... not even close. At a time when there are fantastic free text editors that know a mouse is something other than a nuisance rodent, a small clique of technological throwbacks patiently enter the archaic commands required of vi, as though the last forty years had not taken place.

When people ask for useful vi commands, I am tempted to reply:

Code:
# rm -f `whereis -b vi`
Newbies: the above is a joke, don't type it.
 
Old 09-19-2009, 04:57 AM   #5
j_jerry
Member
 
Registered: Sep 2009
Distribution: fedora 11
Posts: 318

Rep: Reputation: 46
Quote:
Originally Posted by lutusp View Post
Translated, this means that, unless you are either a masochist or a computer software historian, you should choose a modern text editor.

I can use an abacus that is ingeniously connected to a computer, but I would prefer to use something a bit more up-to-date. By the same reasoning I would prefer any editor -- any editor -- over vi. My antique program Apple Writer, which ran on the Apple II and was terribly limited by modern standards, easily outperformed vi.

There are dozens of programs more usable than vi, whose command set was originally designed to avoid an unnecessary waste of paper at a time when all computer transactions were conducted on a paper teletype terminal, at great cost and expenditure of time. (I was obliged to use vi while working on the NASA Space Shuttle in the early 1970s.)

The appearance of the first glass terminal ought to have marked the end of vi's useful life, but no ... not even close. At a time when there are fantastic free text editors that know a mouse is something other than a nuisance rodent, a small clique of technological throwbacks patiently enter the archaic commands required of vi, as though the last forty years had not taken place.

When people ask for useful vi commands, I am tempted to reply:

Code:
# rm -f `whereis -b vi`
Newbies: the above is a joke, don't type it.
Not everyone can agree with you(atleast I can't). I don't understand why you hate vi this much; atleast the popularity of vi just does prove that it is NOT as BAD as you're saying

Last edited by j_jerry; 09-19-2009 at 05:32 AM.
 
Old 09-19-2009, 05:08 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389
@lutusp:
Quote:
Translated, this means that, unless you are either a masochist or a computer software historian, you should choose a modern text editor.
I totally disagree with that and it doesn't have anything to do with the original question.

All text editors have a learning curve and some editors you like and some you don't, a very personal choice.

And be very careful with the rm command you put down (a joke I know, but still....).

@hadimotamedi: Can't you use the mouse to select (part of) the text and paste it into the other vi session?
If you have gvim installed as well, try to use that one, it comes with pulldown menu's and copy/paste options (not limited to one session).

Hope this helps.
 
Old 09-19-2009, 05:17 AM   #7
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Code:
"kyy
will copy a line in buffer k

Code:
"kp
will paste the content of buffer k

vi has 26+1 buffers; you can acces them with a double quote followed by the letters a to z and this can be used when editing 2 or more files (e.g vi abc.txt def.txt). One buffer does not have a letter and only works on the current file.

see http://sparky.rice.edu/vi.html and search for buffers
 
Old 09-19-2009, 05:28 AM   #8
j_jerry
Member
 
Registered: Sep 2009
Distribution: fedora 11
Posts: 318

Rep: Reputation: 46
Quote:
Originally Posted by hadimotamedi View Post
Thank you very much for your reply . But I meant copy from one file and paste to the other file , that both of the files are being opened concurrently in separate vi sessions . Can you please do me favor and modify your proposed procedure to get through ?
Thank you in advance
Open both of your files:
eg:


Code:
vi file1 file2
press CTRL+W,N

then enter :n

you'll see two interchangeable windows; each window represents your file1 and file2

switch between windows using Ctrl+W, W

then copy and paste like i said before

Last edited by j_jerry; 09-19-2009 at 05:41 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to copy/paste a line in nano editor smp0219 Linux - Newbie 7 01-03-2016 06:40 PM
Inquiry:How to Search/Replace in vi text editor hadimotamedi Linux - Newbie 1 09-07-2009 11:57 PM
Inquiry:How to copy/paste in vi text editor hadimotamedi Linux - Newbie 7 08-31-2009 06:58 PM
Copy Text File and Paste to /hdd CD-RW aquatux SUSE / openSUSE 3 12-29-2006 06:32 AM
Which light text editor can copy text from file and paste in browser? davidas Linux - Software 9 03-06-2006 11:28 AM


All times are GMT -5. The time now is 08:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration