tags:

views:

51

answers:

3

how to copy from other file with ctrl-c and in vi editor with p yank (paste), i have no idea!! thinks

+1  A: 

You can't. The yank buffer is private to vim, not shared with the system clipboard.

florin
While this is technically true, you can open several files at once and display multiple as well in the same vim session.
Bruce Armstrong
@Bruce: and? You still cant Ctrl-C in one window/buffer and paste with 'p' in another window/buffer.
florin
agree... you just don't use ctrl-c to "copy"
Matthieu
You are right, it seems a lot of trouble to try to avoid using ctrl+v. I just have a hard time accepting "can't" when it comes to computers. You could spend the time to alter gvim to use the clipboard for the main buffer. Its not impossible, its just not worth the effort. I apologize for the inadvertent troll.
Bruce Armstrong
+1  A: 

Once you have yanked (copied) text in vi, you can type <ESC>:e filename to open another file for editing. Your yank buffer will still be the same, letting you paste into the other file. You must be copying text from one file in vi into another file in vi.

If you want to paste text from outside of vi, you need to setup your terminal and vi specially to allow that.

Alan Geleynse
Optionally, you can do ':split otherfile' or ':vsplit otherfile' to show both the original file and the destination file you want to paste the lines into.
Pete
+2  A: 

You can also do: :r filename

This will pull in the file. It can also be used for output from a command:

:r! grep some_text file
:r! which perl

The other way is to use buffers.

:e other_file.txt

Once you yank, you can :bn to switch to the other buffer and paste

If you are just concerned about pasting, ctrl-v or shift+insert also work to paste the contents of the clipboard.

Bruce Armstrong
than muss be with ctrl v in other_file.txt, but i wannt
Abdelillah Farka