babun: copy/paste from windows clipboard into vim?

13.6k views Asked by At

right-clicking while at the prompt dumps the contents of the clipboard into the shell, but in vim it just switches to VISUAL mode and does nothing. How do I workaround this?

https://github.com/babun/babun/issues/97

5

There are 5 answers

0
Zaboj Campula On

There are several variants how to run vim under MS Windows. Let assume you run console vim (not gvim) under cygwin.

The option mouse controls the vim mouse behavior. When you set the option :set mouse= then right click pastes the windows clipboard to vim. When you set the option to set mouse=a vim tries to interpret the mouse click somehow in all modes and it is a switch to visual mode when vim is in normal or insert mode.

See :help mouse for details.

2
LukeGeneva On

Running the following command worked for me. Essentially just adding to your vimrc.

echo "set mouse-=a" >> ~/.vimrc
0
Robokitty On

UPDATE: If its just a couple lines, ctrl c whatever you want to paste go to vim editor and just right click with your mouse where your arrow is at; this will paste everything. It is a faster approach, however everything will be paste as a comment.

I had tried other things before, but this is the only way it worked for me.

For Window users and beginners like me:

  1. In your Windows editor ctrl + c the text or code you want.
  2. In vim, press Esc (normal mode).
  3. Type :set paste, then press i. Insert (paste) will appear to indicate you can now paste your text.
  4. With arrow keys, go to the place you want to paste your text.
  5. With your mouse click and the text will get pasted.

To get out from Insert(paste) mode:

  1. Press Esc, then type :set nopaste. Press i and you will be back to normal Insert mode.

Hope this helps!

0
michael On

Adding to the various other solutions: if you're getting the --visual-- mode when right-clicking into vim (babun) when trying to paste from the clipboard, you may try to paste by using the following (in "esc" edit mode): "*p

That is: keep holding shift down to type double-quote (") followed by *, then type a lower-case p

1
kasi On

While in vim, try tu use shift + Mouse right click