4

Holy moly guys ... This question has been asked on all boards everywhere on the internet.

I've read everything and I've gone beyond page 2 on Google search results

I am pleading can someone help me figure this out

I have seen answers like "it's hardcoded into the system". Why???

Enough rambling, now for the problem:

Problem: I need to disable the middle-click paste function

Corolary: I still need to be able to scroll using the middle button.

I am a software developer, using a Thinkpad keyboard. The one that has a trackpoint for a mouse.

I need to be able to scroll in editors like VS Code or Sublime Text without accidentally pasting the clipboard into the code without realizing it (which breaks the code)

I also need to be able to scroll using the trackpoint mouse + middle button.

Non-solutions:

  • turning the middle button completely off. I need it to scroll.
  • use Vim/Emacs (I have seen people suggest this)
  • Create an elaborate bash script with a while-loop that continuously blocks pasting if the event originates from the middle button

I believe this problem stems from the fact that this only affects those with thinkpads, since they are the only ones that have a trackpoint and a middle click button on the keyboard. Most people use a mouse with a scroll wheel so it's much harder for them to accidentally click the scroll wheel to paste.

Kind regards:

A ctrl + v user

mpanczak
  • 3
  • 2
isebarn
  • 141
  • Please edit your question in an attempt to be concise and specific. The rambling can be omitted. This is a Q&A site that collects information based on user problems for the perusal of future users. – vanadium Jul 18 '22 at 11:28
  • 3
  • it is indeed hard-coded into the system ("why" is irrelevant in this case, it just is) and therefore any way of fixing the issue is a "hack". It seems like you are looking for some kind of magic solution that somehow the entire internet hasn't found yet. Perhaps there is one, but I am not optimistic. – Esther Jul 18 '22 at 14:41
  • FWIW it appears KDE Plasma on Wayland has implemented a way to disable middle-click to paste about a month ago. In X11 there is still no good way to disable the feature, as it is indeed hard-coded. – Esther Jul 18 '22 at 14:46
  • I disagree, the "why?" is relevant because if there is a reason for it that is relatively reasonable, I might be able to just accept that there is a good reason for it, but if it is "it just is" like you put it, then it's a design flaw in the system.

    And yes, I would like a magic solution, who woulnt? I was hoping for something that I might not have happened upon yet or something someone may have figured out or most likely, something recent (like the wayland thing, which didnt work btw) that could be done because most of what I've seen is pretty old

    – isebarn Jul 18 '22 at 17:22
  • 1
    And my question is extremely specific, I am detailing exactly why its a problem for me, and I said what I've tried doing. The reason for the "rambling" is because I'm trying to convey exactly how exhausted I am by this absurd problem, it affects my work and I've even had to stop using VS Code, because when doing side-by-side comparisons on git diffs you can edit and I've accidentally pasted my clipboard into code when reviewing my own changes and pushed completely breaking code to repositories, so now Im stuck using git diff in the terminal – isebarn Jul 18 '22 at 17:23
  • 1
    @isebarn there are 3 different "clipboards" built into X11. one uses select to copy and middle-click to paste, another uses ctrl-c and ctrl-v. The second was replaced by Gnome-native clipboard. It was this way in Unix, and most/all Linux adopted the behavior. The "primary selection" clipboard (which uses select and middle-click) is actually an entirely different clipboard than the system one. The select/middle-click behavior is hard-coded, not sure why but it is. – Esther Jul 18 '22 at 19:05
  • Most likely the changes from KDE Plasma on Wayland haven't made their way into a release yet, it's only from last month. But they should get released eventually. – Esther Jul 18 '22 at 19:07
  • this answer, in addition to suggesting a hack, explains why it can't be worked around – Esther Jul 18 '22 at 19:08

2 Answers2

4

For VSCode there is a setting controlling this:

"editor.selectionClipboard": false (false corresponds to off)

(source: Disable middle-click paste · Issue #14610 · microsoft/vscode)

It is not named very intuitively, but it was the thing that finally stopped the behaviour in VS Code for me. In Sublime it was already disabled potentially due to other things I've already implemented:

  • Gnome Tweaks > Mouse > Disable Middle click paste
  • Running XMousePasteBlock on startup
0

I fixed it with input remapper. It has a graphical interface that lets you disable or modify usb inputs before other applications see them. I disabled the middle mouse click and scroll still works.