1

In vim 8.0 when I try to paste a vim command from clipboard, it behaves as if vim was in insert mode: the command is pasted into the file itself instead of being executed.

I'm using mintty. Mouse is off. Same result when pasting from the terminal's context menu or using a hotkey.

  • It works for me in command mode. If you are not in command mode it paste as insert mode. – matzeri Feb 20 '17 at 16:51
  • 2
    I WAS having the same problem, though for me it started after patching my Fedora 25 system. I have been pasting VI and VIM commands for more than 30 years and find this change of behaviour very annoying... Link to my question, and the solution.... unix.stackexchange.com/questions/364047/… – anthony May 11 '17 at 0:46
2

Vim 8 added support for "bracketed paste" (wherein the terminal wraps pasted text in escape codes which indicate to vim that the text is a paste vs a typed string; see Patch 8.0.0210). It seems like the default behavior is to automatically enable insert mode before accepting pasted text.

You can disable bracketed paste and go back to the old behavior by adding set t_BE= to your vimrc.

1

I usually manually type the : to get the command prompt, then paste the command in. Vim doesn't care that a command starts with a double ::.

  • Only works for a single vim command line. I often paste 200+ vim commands in one single paste, to do major reformatting of thousands of files. – anthony Aug 6 at 1:11
  • @anthony The user in the question asked for a way to "paste a command", not 200. Also, for 200 editing commands, you're better off saving them in a separate Vim script and then executing that. This would additionally give you the opportunity to review the commands, change them etc. – Kusalananda Aug 6 at 6:23
0

I also had this problem, And a detailed solution has also been given, explaining not only how you can stop this (using set t_BE=) but also how you can stop it just for the vim 'command mode' allowing you to paste using 'paste mode' from 'insert mode'.

Link to my question and answer... Stop vim pasting selections as text!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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