LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How do you copy and paste a line in VI? (https://www.linuxquestions.org/questions/linux-general-1/how-do-you-copy-and-paste-a-line-in-vi-321249/)

Thaidog 05-08-2005 05:23 AM

How do you copy and paste a line in VI?
 
It would be great to be able to copy and paste a line in VI. Is there a command to do that?

acid_kewpie 05-08-2005 05:34 AM

hit v to enter visual mode, select the text you want and hit y to copy. then hit p to paste in the destination

you should print out a cheatsheet, or become more familiar with the manpages to avoid needing to ask questions like this. Gentoo have a great cheet to print out: http://www.gentoo.org/doc/en/vi-guide.xml

Thaidog 05-08-2005 05:39 AM

I've got a cheat sheet going... that's basically the last thing I needed. thanks for the help!

frob23 05-08-2005 05:46 AM

Please note: "v" is a vim command and is not supported in all implementations of vi. I do love visual mode though... and vim adds a lot of things to make vi easier to use on a daily basis.

The easiest way to copy a whole line (which will work in any version of vi) is "yy" and then "p" or "P" where you want it.

Almost any movement command can be used in conjuntion with "y" to select text.


All times are GMT -5. The time now is 03:39 AM.