Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

selecting in visual mode to paste outside vim window

Tags:

I need to paste some selected block in visual mode to outside of vim. Currently I need to select this block manually from mouse to paste outside of vim.

As selecting texts in visual mode is easier ,it would be efficient to select some text for pasting outside of vim.

like image 364
shampa Avatar asked Oct 12 '11 23:10

shampa


People also ask

How do I paste something outside of Vim?

We can use the “+p and <Ctrl+r>+ in normal and command mode, respectively. However, it might be more convenient if we use the <Ctrl+Shift+v> hotkey since it does the same thing as “+p. Similarly, <Ctrl+Shift+c> will yank the text into the + register to be available for pasting outside of Vim.

How copy from vim editor to outside?

Hold down the SHIFT key and mouse select text to copy it. Then paste in other program with CTRL + v .

How do I paste in insert visual mode?

Before pasting into vim, enable paste mode by entering :set paste . Press i to enter insert mode. The status bar should say -- INSERT (paste) -- now. Press the right mouse button to paste in your stuff.

How do I use visual block mode in Vim?

To enable the Visual block mode in Vim, you have to try out the “Ctrl+V” command within the normal mode. You can see that the new. txt file has been opened in the Visual Block mode.


2 Answers

You could yank the text into the + (plus) register, that is mapped to the system clipboard. Just select the text in the mode you like and then type "+y.

like image 64
etuardu Avatar answered Sep 20 '22 19:09

etuardu


Disclaimer: Linux

So what I have noticed is you need clipboard support compiled in to your vim. I ended up compiling my own vim, which had the clipboard support. To check run vim --version and look for a +clipboard or a -clipboard, if it's + then yay you have it, if it's - then you need to compile vim yourself or download a version with clipboard support compiled in. Then the answers people have said seem to work. For me "*y copies into the buffer that is pasted by pressing the middle button, and "+y copies into the buffer which is the normal control + c or on the terminal control + shift + c so what I put into my vimrc was

map <C-c> "+y 

that way doing control + c me paste it somewhere else by pressing the exact same command

:wq

like image 36
Jacob Minshall Avatar answered Sep 20 '22 19:09

Jacob Minshall