8

I've been using vi for 40 years. A week ago I upgraded; Disaster struck! The upgrade was to

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 4 2018 23:38:28)

I run this on xterm under Cygwin (under Windows 10).

I understand that I can insert text from the clipboard by pressing, e.g. 'a' followed by a middle-click of the mouse. Fine. That still works.

But for the last three decades, when in vi command mode I can execute a string of vi commands from the clipboard by pressing middle-click. THAT NO LONGER WORKS. If vi is not in insert mode it immediately goes into insert mode (as if 'a' were pressed) when I middle-click to paste.

What's happening? What's the workaround?

On another board, someone mentioned commands like

:set paste
:set nopaste
:set mouse=

I don't know what those commands are supposed to do, but none of them solves my problem.

Thanks in advance!

2
  • 2
    Wow! 40 years, OMG! My 23 years is just a tiny experience :-)
    – peterh
    Nov 17, 2018 at 19:03
  • Running Vi IMproved 8.1 on an Ubuntu Gnome terminal ssh'd to a Debian VM, I need :set mouse= to be able to paste even in insert mode. A pox on whomever made this "improvement." (I don't have the same issue in the same terminal for other VMs and contexts, so no idea what's different about this one.) Sep 18, 2020 at 16:01

2 Answers 2

9

set mouse= is the fix for the problem, with set t_BE= substituted in an xterm environment. The 'bug' these fixes solve was actually intended as a 'feature': creating an obstacle to pasting vi commands would be good if malicious code were somehow inserted onto user's clipboard.

Kudos to a guy named Elijah, on another message-board, who researched and solved this problem.

4
  • 1
    And what's with all the "Edited by ..."??? Leaving my name on words that aren't my own??? I could understand this if someone used obscenities. But, as is, it seems like pretentious anal-retentive policing! (Though soon this remark will doubtless be edited away! ) And, BTW, in the unlikely event that you're interested in improving your user intrface, be aware that with buttons like "Save Edits" USE OF THE ENTER KEY TO MEAN "SAVE EDITS" IS REDUNDANT. Some us old fogeys like to use ... gasp! ... paragraph breaks and such!
    – user19858
    Nov 19, 2018 at 8:22
  • 4
    Dear jdallen, I cannot understand your concerns: this site is a collobarative effort by the people who ask, answer and try to improve the quality of posts. If you do not like an edit, you can raise your voice. But in your case I do not see a reason. People do not only fix formatting or tags, but also correct typos, improve English, clarify text etc. This is helpful. Regarding requests about the site itself there is a dedicated subpage vi.meta.stackexchange.com. However, your issue with comments will unlikely change. But for sure this is not the place to discuss this.
    – Hotschke
    Nov 19, 2018 at 11:06
  • 2
    For clarity: The solution to this problem is to enter :set t_BE= in vim itself. The mention of "in an xterm environment" in the answer gave me the (incorrect) impression that you need to change your termcap/terminfo settings. Jul 9, 2019 at 7:12
  • I'm in an xterm editing a GPG-encrypted file with no obvious way to save (especially in vi) so I've been just triple-clicking on a line near the top of the file to save - like ":%!gpg -tear <user> > <filename>" (obviously with actual args) and then middle click (taptaptap .. .tap). This lets me continue using my ridiculous hack in my script, with "gpg -v <$file | vim -nC '+set mouse= t_BE=' -" I can't decide whether to be horrified at myself and just write a real app, but in the meantime, thanks for letting me ignore my issue for a while yet :-) Aug 21, 2019 at 5:20
-2
q:"+p<cr>

This mapping should paste from your clipboard and execute. Map it to whatever you want and you are done.

By the way the answer you posted seems to be for an entirely different purpose, and the first two lines contradict, so one of them is redundant.

2
  • 2
    I found the correct answer via another message board: set t_BE= is the xterm equivalent of set mouse= and solves my problem.
    – user19858
    Nov 18, 2018 at 6:03
  • 2
    And I just learned that Enter terminates comments. Friendly? The "bug" was actually a "feature": Some malicious agent might have put a virus into my clipboard. By the way, I entered these commands one by one, ignorantly trying the silly ones only when 'set mouse=' (almost correct!) failed.
    – user19858
    Nov 18, 2018 at 6:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.