1

This has not just once, but happened many times. I'm not sure what I'm doing wrong.. it tends to occur more frequently during remote control. I would set the mouse cursor at a certain position where I would paste, then it either goes to somewhere really far down or somewhere up.. until after meaningless trial/error(of which pattern I do not understand) it will at one point find where I'm looking for.

Does anyone know why this is so? As I tried to recreate for capturing of screenshots, it now works fine, again with no logic -_-

7
  • 1
    What does :set mouse? output? Commented Jul 9, 2019 at 12:00
  • oh i think this may work. can I also ask why the format becomes unstructured when I paste texts that are originally formatted nicely? Commented Jul 9, 2019 at 12:03
  • Because Vim tries to indent the pasted text. See askubuntu.com/questions/620980/… Commented Jul 9, 2019 at 12:20
  • 1
    I didn't ask you to run :set mouse. I asked what the output of :set mouse? is. Commented Jul 9, 2019 at 12:23
  • 2
    VIM is not supposed to be used with mouse :) but if you use it you have to set it properly Commented Jul 9, 2019 at 12:37

2 Answers 2

2

This happens to me from time to time, when I copy a .vimrc from a regular desktop to a machine I use only through SSH or other remote session. I normaly use set mouse=a via .vimrc. On remote machines this breaks also depending on the version of Vim. Pasting with middle mouse scrolls up or down a few lines and drops the clipboard content in that new location instead of Vim-cursor position.

I fix this by simply removing the set mouse=a it pastes as expected but does not disable mouse navigation. To unset mouse use set mouse=.

For some versions of Vim this was also fixed by scrolling a few lines up and down with the mouse.

Nevertheless I admire the work of art of so many that makes it possible to translate my local pointer device actions into terminal commands understood by a program far far away and not destroying the universe.

1
  • Yes, indeed, your last paragraph is right-on-the-money. :) Commented Oct 5, 2024 at 18:34
2

I just found a Reddit post that fixes it for me (but I couldn't find any Stack Exchange or Stack Overflow article that answered the question...).

My document's text was getting overwritten, and my cursor was in the wrong place upon resizing the VIM window via closing/expanding two fingers on the touchpad.

  • I had shopt -s checkwinsize enabled in my ~/.bashrc configuration file (I checked by shopt | grep checkwinsize and got checkwinsize on), but the error still occurred.

Fix:

1st enter VIM's Insert mode by pressing i, and then pressing right click (on your mouse or touchpad) to paste whatever's in your computer's clipboard (if you already copied a message from your terminal or somewhere else like an external browser using CTRL+C) to paste.
If you don't enter Insert Mode (the indicator "-- INSERT --" will be at the bottom of your file once you're in this mode) before pasting, pasting will overwrite the text below, even if you provide space/newlines for it to not overwrite your document.

4
  • (1) I looked at the Reddit page you linked to, and I don’t see your answer there.   Can you clarify where you got it?    (2) Normally, when one types i and then p into vim, one inserts the letter p as text.   Please clarify how your answer works. Commented Oct 9, 2024 at 21:54
  • @G-Man: 1) I didn't personally submit an answer on the Reddit forum, so that's why you didn't find it. I was just reiterating the Reddit post's answer in a more holistic way that may solve other slight issues when problem-solving. Nvm, I just checked the Reddit post again and the answer I referenced is no longer there. Idk why their answer would get removed though. The answer I referenced stated to press i and then press p, instead of simply pressing p. 2) Normally true, but it wasn't true in that specific case for whatever reason I don't fully understand. Commented Oct 12, 2024 at 18:59
  • Temporary note: I can't check internet archive for a less recent version of the cited Reddit article rn due to IA's recent cyberattack Commented Oct 12, 2024 at 19:05
  • After playing around with it more, I think the method I described only works with right click pasting and does NOT work with i then p Commented Oct 28, 2024 at 2:12

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.