You are not logged in.

#1 2022-01-15 11:00:05

boscaiolo
Member
Registered: 2016-05-02
Posts: 19

not solved: vim broken -- middle mouse pastes different clipboard

New Arch install , includes 'extra/vim 8.2.3890-1'.

Every other app seems to work normally, pasting last highlighted text
from anywhere with the middle mouse button. But not vim. On other
distros, vim behaves normally, so I assume this is a problem created
somehow in Arch.

I have discovered there is a file /usr/share/vim/vimfiles/archlinux.vim
which seems to map shift-insert to middle-mouse, and this led me to
try shift-insert in vim instead of middle-mouse. This does paste the
expected text, but middle mouse is such a reflex action, used dozens
of times every day for over twenty years in every program, that it is
crazy to have to use a weird two-key alternative in vim.

Does anybody here know a way to correct this?

Last edited by boscaiolo (2022-01-30 18:53:19)

Offline

#2 2022-01-15 14:43:40

seth
Member
Registered: 2012-09-03
Posts: 51,213

Re: not solved: vim broken -- middle mouse pastes different clipboard

vim or gvim?

If vim, what terminal? Does mmb pasting into the terminal work in general and do you have "set mouse=a" in your vimrc?

Offline

#3 2022-01-17 16:10:40

boscaiolo
Member
Registered: 2016-05-02
Posts: 19

Re: not solved: vim broken -- middle mouse pastes different clipboard

seth wrote:

vim or gvim?
If vim, what terminal? Does mmb pasting into the terminal work in general and do you have "set mouse=a" in your vimrc?

I am using vim.

mmb paste fails in vim in xterm (my normal terminal emulator) and Uxterm, but also in qterminal and terminator. It does not work in vim in virtual terminals

Oddly, mmb works as expected in vim in xvce4-terminal.

mmb pasting works in nano in all terminals.

Other than in vim, mmb pasting works as usual in all terminals, and in all other programs that I have tested, even libre-office.

Yes,  "mouse=a" is set in vimrc.

The set-up is identical to that I use in Debian and other distros, where mmb does work as usual in vim.

EDIT... SOLVED

:set "ttymouse=" solves the problem.  By default, it is evidently set "ttymouse=sgr". I gather this may be for screen (?). 
Unsetting ttymouse eliminates the problem with mmb paste.

Last edited by boscaiolo (2022-01-17 16:22:56)

Offline

#4 2022-01-30 18:51:59

boscaiolo
Member
Registered: 2016-05-02
Posts: 19

Re: not solved: vim broken -- middle mouse pastes different clipboard

In fact it is not solved.

Further tests show that ":set ttymouse= " breaks selection with the mouse (it includes
line numbers) ,  enables paste from the same or another xterm, but does not paste from
Firefox , which is the place I most commonly copy from (and which is possible under
Debian.) It is confusing because the behaviour of mouse select and mmb paste seem to
vary, depending on whether the ttymouse option is set in vimrc or changed during
the current session.

I have tried ":set clipboard=unnamed,autoselect" with both or either one of these
two parameters but "clipboard" does not appear in the list of Options. I imagine either
this is an incorrect setting (I found it in a couple of places including
https://github.com/rkitover/vimpager/issues/45 ) or vim needs to be compiled differently.

There is also a mention of vim being compiled with X11 support. This might explain the
difference between the version shipped with Debian and this version. But I notice one
other difference between Debian and Arch: in Debian you can mmb paste anywhere,
including to and from a console. in Arch it seems as though vim, X11, xterm and
console all have separate clipboards. I am out of my depth here. Can anyone comment?

Offline

#5 2022-01-30 19:06:42

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: not solved: vim broken -- middle mouse pastes different clipboard

I sometimes use the MMB to paste in vim, but, it doesn't work if only using MMB I have to use 'Shift+MMB' have you tried that?
Using plain xterm and vim here...

Offline

#6 2022-01-30 19:16:55

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,732
Website

Re: not solved: vim broken -- middle mouse pastes different clipboard

Just having an empty ~/.vimrc makes middle button pasting work for me under X & Wayland in xterm & foot. No need for any specific mouse options at all.

Offline

#7 2022-01-30 19:40:44

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: not solved: vim broken -- middle mouse pastes different clipboard

Head_on_a_Stick wrote:

Just having an empty ~/.vimrc makes middle button pasting work...

Indeed it does, but, 'reinstalling' .vimrc pastes an 'old' clipboard entry...
Disabling 'set mouse=a' does paste with only MMB.
Now, I don't mind I'm used to 'Shift+MMB';-)

Offline

#8 2022-01-30 21:30:27

seth
Member
Registered: 2012-09-03
Posts: 51,213

Re: not solved: vim broken -- middle mouse pastes different clipboard

I've "ttymouse=xterm2" and "mouse=a" and no MMB issues whatsoever

in Arch it seems as though vim, X11, xterm and console all have separate clipboards.

Absolutely not. There's one primary buffer.
(Well, I can't paste in the console at all since there's no mouse to begin with)

I assume the problem in this chain is gnu screen.

Offline

#9 2022-01-30 21:50:01

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: not solved: vim broken -- middle mouse pastes different clipboard

seth wrote:

I've "ttymouse=xterm2" and "mouse=a" and no MMB issues whatsoever

Hmmm, what have you installed or changed?
With gvim this is indeed working as advertised but when using vim(vim-minmal) it won't, at least not without disabling "mouse=a" ...

Offline

#10 2022-01-30 21:54:52

seth
Member
Registered: 2012-09-03
Posts: 51,213

Re: not solved: vim broken -- middle mouse pastes different clipboard

Nothing special - the TE might be relevant though (see this thread where I'm currently blaming GNU screen)

Offline

#11 2022-01-30 22:01:05

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: not solved: vim broken -- middle mouse pastes different clipboard

seth wrote:

Nothing special - the TE might be relevant though (see this thread where I'm currently blaming GNU screen)

TE??
Please add that thread link tongue I don't have screen installed BTW.

Offline

#12 2022-01-30 22:06:32

seth
Member
Registered: 2012-09-03
Posts: 51,213

Re: not solved: vim broken -- middle mouse pastes different clipboard

"Terminal Emulator"

Offline

#13 2022-01-30 22:13:12

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: not solved: vim broken -- middle mouse pastes different clipboard

seth wrote:

"Terminal Emulator"

Of course, you 'hipsters' need to shorten everything big_smile

What about that 'blame GNU screen' thread link?
I even tried googling it...

Offline

#14 2022-01-30 22:14:47

seth
Member
Registered: 2012-09-03
Posts: 51,213

Re: not solved: vim broken -- middle mouse pastes different clipboard

https://bbs.archlinux.org/viewtopic.php … 1#p2019301

seth wrote:

I assume the problem in this chain is gnu screen.

Offline

#15 2022-01-30 22:23:05

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: not solved: vim broken -- middle mouse pastes different clipboard

Thank you, but duhuh I thought it was a thread giving some technical information showing the actual culprit.
Well, I can assume or guess it's not screen for I'm botnot using it!;-)

edit: Oh, I use the tools as stated in #5 xterm and vim(vim-minimal)
using XTerm Tmux & vim yields the same result BTW.
Since you said TE:-) might be relevant...

Last edited by qinohe (2022-01-30 22:54:09)

Offline

#16 2022-01-31 09:13:31

boscaiolo
Member
Registered: 2016-05-02
Posts: 19

Re: not solved: vim broken -- middle mouse pastes different clipboard

Thanks seth and qinohe and Head_on_a_Stick...

I had not thought of completely eliminating mouse= .
It's complicated , as they say. 
   - I remove "mouse=..." from .vimrc ; mmb paste works from the same or any
                                                             other xterm and also from libreoffice and
                                                             from evince, but not from Firefox. With or
                                                             without 'shift-'
     But I notice that ttymouse has automatically been set to the last value used.
     Unsetting ttymouse seems to have zero effect.

Suddenly, this looks like a Firefox problem rather than Vim! So I tried Chromium. MMB
paste works fine in Chromium. The difference between Debian and Arch must lie in
Firefox. Tant pis.

The only thing I lose without mouse=a is the mouse select with ":set nu",  which
selects the line numbers. But that is just a bad habit of mine. using 'v'isual and 'y'ank
or '12,34y' with 'p' is the more "correct" way I suppose.

Apologies to all. I misdirected you it seems.

Offline

#17 2022-01-31 12:55:44

seth
Member
Registered: 2012-09-03
Posts: 51,213

Re: not solved: vim broken -- middle mouse pastes different clipboard

Does it help if you "export GDK_CORE_DEVICE_EVENTS=1" to firefox?

Offline

#18 2022-01-31 17:20:05

boscaiolo
Member
Registered: 2016-05-02
Posts: 19

Re: not solved: vim broken -- middle mouse pastes different clipboard

seth wrote:

Does it help if you "export GDK_CORE_DEVICE_EVENTS=1" to firefox?

Yes! It does seem to solve the MMB paste problem to and from Firefox..

But, in vim, there remain interactions with "mouse=a" and "ttymouse=sgr".

If I remove both from .vimrc, ttymouse is still set by default -- I am unsure how.
And only if I unset it before doing anything else in vim with ":set ttymouse="
does MMB-paste work as expected. Otherwise, pasting into vim sometimes
comes with several extra lines of text above or below the intended section,
or sometimes just the previous selection appears.

I have become confused by the permutations, so I will simply use ":set nonu" before
copying and pasting longer sections of text from vim. And also ":set ttymouse="
whenever I get rubbish pasted.

Thanks again, seth.

Offline

#19 2022-01-31 18:05:51

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: not solved: vim broken -- middle mouse pastes different clipboard

boscaiolo wrote:

I have become confused by the permutations, so I will simply use ":set nonu" before
copying and pasting longer sections of text from vim. And also ":set ttymouse="
whenever I get rubbish pasted.

Maybe use something like plugin 'vim-airline' it shows line numbers already.
This way you never need to use line numbering which I dislike and solve this way.
Just a matter of getting used to;-)

Offline

#20 2022-01-31 21:53:45

seth
Member
Registered: 2012-09-03
Posts: 51,213

Re: not solved: vim broken -- middle mouse pastes different clipboard

":set mouse=a" allows me to select line numbers in a sane way (ie. "not")?
@boscaiolo, does ":set ttymouse=xterm2" work better? (despite gnu screen)

Offline

#21 2022-01-31 22:41:56

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: not solved: vim broken -- middle mouse pastes different clipboard

seth wrote:

":set mouse=a" allows me to select line numbers in a sane way (ie. "not")?

No, it does not, using line numbering & using a mouse to select multiple lines includes line numbering.

Offline

#22 2022-01-31 23:00:22

seth
Member
Registered: 2012-09-03
Posts: 51,213

Re: not solved: vim broken -- middle mouse pastes different clipboard

Definitifely not for me. Not inside, not into a different client and the line numbers are also not selected. That would drive me crazy.
I instead will get the when unsetting ":set mouse="

Offline

#23 2022-01-31 23:10:13

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: not solved: vim broken -- middle mouse pastes different clipboard

Yeah, well it drove me crazy at first, now I'm using 'vim-airline' to show me the line number I'm on.
I've gotten used to it over the years, though, if I could just figure out what I should change...

Offline

#24 2022-02-01 07:33:38

seth
Member
Registered: 2012-09-03
Posts: 51,213

Re: not solved: vim broken -- middle mouse pastes different clipboard

I'd start w/ a clean vimrc and see how that behaves w/ enabled mouse.
Again: the TIE figh… TE may be *very* relevant here, in doubt try xterm (no tmux, no screen)

Offline

#25 2022-02-01 15:29:46

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: not solved: vim broken -- middle mouse pastes different clipboard

Thank you seth, and sorry @boscaiolo, I don't mean to hijack your thread...
seth, I'll create a new thread for this when I have a little 'extra' time to play with this and still can't figure out what's the problem;-)

Offline

Board footer

Powered by FluxBB