How do I copy in vi editor?

I am using vi editor and I want to do copy operation but unable to do it. When I select the word and right click on it, there is no "copy"option but only "paste" option is there. What is wrong going on here? Is there is any package needs to be installed for vi/vim editor ?

Note : It could be better to obtain "copy" option on selection for permanent fix but I got solution below i.e.to use yank command . Its is working fine within the file . But if there are 2 files open on separate tabs, I am still unable to copy data from one file to another. enter image description here

3

2 Answers

You are mixing up copy/paste in terminal and in vi/vim.

When you mark a word in the terminal, it is automatically copied, never mind if you are in vi or an other app, or just have some output from a command or even text you have written yourself.

In vi you copy with the y (yank) operator:

  • yy copy whole line
  • yw copy word (from cursor position til next whitespace.
  • y<space> copy character

And paste with the p and P operators. Read the vi manual page for full documentation.

Also you could maybe use a graphical editor like gedit.

5

In some terminals you can use for copy:

CTRL SHIFT C

and for paste:

CTRL SHIFT P

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like