Using middle mouse click to paste text enters insert mode

vim

How can I switch off vim to automatically enter edit mode on middle mouse button click?

Background: I like to create command strings like JJJj to concat three lines and then go one line down, select this command string with the mouse and paste it again and again into vim using the middle mouse button. However, recently, vim automatically enters insert mode on middle mouse click rendering this procedure dysfunctional. I don't know whether it's a change in vim itself or of some default configuration of my distribution (Gentoo), but I need a way to switch that off again.

To clarify one thing: I don't have set mouse=a set (neither in my ~/.vimrc nor somewhere else. So for instance, left mouse clicks do not move the cursor to the clicked to location. This is probably the reason, why [cas]es tip to use set mouse= in ~/.vimrc doesn't solve this issue.

Also, I'm talking about vim (in xterm), not gvim.

System details:

  • Gentoo Linux
  • Vanilla Linux 4.9.13
  • X.Org X Server 1.19.3
  • XTerm(327)
  • vim 8.0.386 (seems modified by Gentoo)

Best Answer

This is fully answered here. See the excellent linked answer for details and alternative solution.

Short answer: put :set t_BE= in your .vimrc file.

Related Question