Thomas
Thomas

Reputation: 12087

copying text with the mouse in VIM, why doesn't it work?

I am using both MacVim and console Vim. My shell is ZSH and the terminal is iTerm2.

What I am trying to achieve:

when I'm dealing with the GUI, in other window, sometimes I want a quick copy paste from a VIM window. I can use the mouse to select the text, but:

when using MacVim, the menu shows me to use cmd-c to copy, but whether I do it, or using the context menu it sometimes works and, more than often, it doesn't.

Reading from forums, I've tried to do:

:setmouse=a

but, when I press return it doesn't even acknowledge the line.

So, my simple question is: how can I do quickie copies from a mouse selection in VIM to paste it in another window without have to do anything else that would slow me down?

Upvotes: 2

Views: 3788

Answers (2)

Nefedov Yury
Nefedov Yury

Reputation: 1

The answer is in the :help mouse information: "If your terminal can't overrule the mouse events going to the application, use: {:set mouse=nvi} Then you can press :, select text for the system, and press Esc to go back to Vim using the mouse events." This works for me in MaсVim in iTerm2 terminal.

Upvotes: 0

D. Ben Knoble
D. Ben Knoble

Reputation: 4663

The command is

set mouse=a

but you need clipboard interfaces. See :help "*

I would visually select (with or without mouse) and use "*y, or :yank * if it can be done linewise (sometimes the range is easier to type, like :%y*).

Alternately, disable mouse-reporting (Cmd-R on mac) and use the native copy-paste.

Upvotes: 3

Related Questions