2

Whenever I select something in visual mode in Vim it automatically gets copied. It causes a problem since I have alread something in clipboard to paste in that selected text.

Is there any way to disable this?

Is this due to the fact that my xterm also has similar behaviour?

2 Answers 2

6

This behavior can be caused if certain settings are used for a few specific options.

  • When 'clipboard' contains the autoselect setting, which it does by default under *nix (only applies for normal vim), your visual selection is stored to the * register.
  • When 'guioptions' contains the a setting, which it does by default under *nix (only applies for gvim), your visual selection is stored to the * register.

The * register is synonymous with the clipboard in Windows and the currently selected text (as in select text, then middle-click to paste) in *nix.

'mouse' can also have an effect since if it is set to a or contains both n and v then Vim will receive your mouse clicks and start a visual selection if you click & drag. The behavior of what happens with the contents of the visual selection is still handled by 'clipboard'/'guioptions' though.

Basically, if you're using *nix and the default settings for 'clipboard'/'guioptions' then "* is going to be overwritten when you make a visual selection since that follows what other *nix applications do when you select text. If you're using Windows and the options are as described, then your clipboard is going to be overwritten since "* and "+ both modify the clipboard on Windows.

1
  • That solved my problem, Thanks for such a complete answer
    – Yogesh Arora
    Mar 16, 2010 at 20:52
0

This is Unix specific. I'm not aware of anything that you can do to change that behavior within vim.

X has the concept of a selection buffer, which is whatever text is currently selected. In addition, a gvim compiled with +xterm_clipboard supports the standard clipboard, which is used whenever you do Cut/Copy/Paste operations in most applications.

The selection buffer is accessible with "*.The clipboard is accessible with "+.

If you use the main clipboard, its contents won't change with the selection.

You must log in to answer this question.

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