2

When I copy some lines in the VIM by marking and then right clicking sometimes there are some insert operations that happen and the letter 'p' is added to the file.

How can I copy and paste without this issues?

1
  • 1
    What terminal are you using? A number of them treat right-click as "paste"... Jul 2, 2012 at 16:49

4 Answers 4

2

When using VIM there a many better approaches to copy text. VIM is ideally used without a mouse.

To copy full lines, you can type 3yy where you can replace 3 by the amount of lines you want to copy. You can also copy text by range of line numbers :2,5y. Furthermore, you can select lines by enetering visual mode (press v).

Pasting can be done by typing p in normal mode. These ways are eventually much faster than approaches including the mouse.

1
  • v for visual, shift+v for visual line, and ctrl+v for visual block.
    – Rob
    Jul 3, 2012 at 18:19
3

Use the :help clipboard registers to copy to your system clipboard. Depending on your system it might be "* or "+. So for example you can visually select a line using V and then yank to your system clipboard with "*y. MacVim and some other GVims have a system clipboard menu option and hot key built into them. Try mapping the clipboard yank to a key in your ~/.vimrc like:

vnoremap <C-v> "*y

Then you can visually select with your mouse and hit CTRL-v to copy to your system clipboard.

1

Select the text you need then go to the place where you want paste and press right click button. Of course you need to press Insert before this.

0

First, look to map the mouse to this with

vnoremap <RightMouse> "*y

Debugging beyond that: see if your right-click is mapped in an awkward way. Look to guides for how to expressly map these as needed, or examples. Sadly, this may be in the compiled code (of the windows vim app) itself. Look to what remapping options you may have that are unique to Windows.

Remember , as well, to watch for the same behavior on paste. You need to type i before you rick-click, which is paste.

What can often happen is when you right-click is pasting in the string, which then acts just like you were typing. So Vim doesn't enter insert mode until is gets to a character like i or a

1
  • OP trying to get the right-click menu like on windows to perform a copy/cut ... not a paste (yet). Good info though.
    – lornix
    Jul 2, 2012 at 17:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .