LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to copy paste into VIM ? (http://www.linuxquestions.org/questions/linux-software-2/how-to-copy-paste-into-vim-466153/)

EAD 07-21-2006 04:09 AM

How to copy paste into VIM ?
 
Hi.
Some times I have some info from the web or somehere else I want to copy paste into my VIM editror, When I am doing the way I know that is select with the mouse, then copy and i in VIM and shift+insert, It is al not indent at all.
I get something like
The big fox
jump over{
gfgdf
fg
}

well you got the point, so what can I do? I am using VIM 7 btw.

:confused:

jschiwal 07-21-2006 04:37 AM

Press i for insert (or a for append), and then press "shift-insert".

konsolebox 07-21-2006 04:55 AM

press v to start the selection of a block. use the arrow keys to allocate the selection. then press y to set copy or press x to set cut. press p to paste.

prozac 07-21-2006 05:03 AM

if you have 3 button mouse, here is another idea. just highlight any text you would like to paste, fire up vi go into insert mode and just middle_click (the wheel). mind you it only works under X though and I have only tested it with konsole.

Tinkster 07-21-2006 05:13 AM

Quote:

Originally Posted by EAD
Hi.
Some times I have some info from the web or somehere else I want to copy paste into my VIM editror, When I am doing the way I know that is select with the mouse, then copy and i in VIM and shift+insert, It is al not indent at all.
I get something like
The big fox
jump over{
gfgdf
fg
}

well you got the point, so what can I do? I am using VIM 7 btw.

:confused:

My understanding is that vim uses the extension of a file
to do indentation proper. To me that suggests that you're
not using vim like so:
vim my_source.c
and then copy & paste, but rather just fire up vim and paste
into it, which kind of deprives it of its means to tell what indentation
model it's meant to be using?


Cheers,
Tink

konsolebox 07-21-2006 05:28 AM

just in case you're using konsole, the moment you paste a text to vi (using the mouse of course), it's just the same as typing all the characters you copied (based on my observation). so you must press i or anything that will set vi to edit mode before pasting the values.

Edit: i tested copying a c code then pasting it to vi and i got no prob . my vim version is 6.3 2004 june

sailu_mvn 07-21-2006 05:54 AM

use yy to copy and p to paste .
Dont press any insert
Its the easiest way

konsolebox 07-21-2006 05:58 AM

oh yes i remember. that's when you duplicate lines. you can also cut and paste lines using dd to cut and p paste.

EAD 07-21-2006 10:47 AM

you guys didnt under stand!!!
I meant, that I now all the P and yy and i and so on.

I want to take a full text from the www, and like when putting it on a notepad and everything works nice, excat copy, just like it I want it to copy to vim.
Is it possible? and if so . how?

jayemef 07-21-2006 11:19 AM

Sometimes, depending on how Vi is configured (from .vimrc or globally), particularly with any sort of smart indentation, copy and paste can get kinda funky. This is where the :set paste command comes in. While in command mode, just press :set paste, do your pasting as you normally would, and then press Esc to exit. I've had a lot of success with this method.

EAD 07-22-2006 12:39 PM

Quote:

Originally Posted by jayemef
Sometimes, depending on how Vi is configured (from .vimrc or globally), particularly with any sort of smart indentation, copy and paste can get kinda funky. This is where the :set paste command comes in. While in command mode, just press :set paste, do your pasting as you normally would, and then press Esc to exit. I've had a lot of success with this method.

Will it work if I need to paste from something outside VIM ? like www ?

jayemef 07-22-2006 01:21 PM

Yes, that is what it's for. Vi, as you and others already stated, has commands for copy/pasting lines within the same document.

Kovacs 09-05-2006 01:14 AM

Select the text from your browser, enter insert mode in vim and then hold down shift and middle click to paste the text into vim in your terminal.

jayakrishnan 09-05-2006 01:22 AM

shift+insert is the easiest option

gulch 12-12-2006 08:56 AM

Quote:

Originally Posted by jayakrishnan
shift+insert is the easiest option

thanks, I think it is the best answer


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