3

It used to be possible to leave vim in command mode (rather than insert mode) and then paste some copied characters into the vim window to make it execute the characters as a sequence of commands. So you could copy n0dt@ and when you pasted it in, it would search for the next item you last searched for (n), go to the beginning of that line (0), and delete everything up to the first @ character in that line (dt@). Then you could paste it again and it would do it again on the next item, etc.

Now when I paste into the vim window, it somehow detects that I'm pasting rather than typing, and it "helpfully" switches into insert mode and just inserts the literal characters n0dt@, which isn't what I want. Is this a recent change to vim (like within the last couple of years)? Is there a way to turn off this automatic switch to insert mode on paste? (In case it's relevant, I'm running vim in Cygwin, pasting into a mintty window with a right-click.)

12
  • I've only been using vim for 2 years, so I don't know if this is a recent change, but I've always used the 'normal' command (i.e. type 'normal', or just 'norm' in command-line mode), followed by the sequence of things I want vim to do (as if I typed them into vim while in normal mode). :normal n0dt@
    – mattb
    Commented Apr 25, 2021 at 9:42
  • The behaviour you describe is the expected behaviour of Shift+Insert.
    – romainl
    Commented Apr 25, 2021 at 16:14
  • 1
    Neither of those is what I want. I want to execute the commands by pasting them, without typing anything. Typing ":normal n0dt@" is more typing than simply typing "n0dt@". I want to execute the commands represented by "n0dt@" without touching the keyboard at all, by clicking the right mouse button once, to paste the characters "n0dt@" into command mode (not command-line mode). Shift+Insert just inserts the characters as text, just like pasting does currently.
    – Neo
    Commented Apr 25, 2021 at 17:31
  • Clicking the right mouse button does Shift+Insert in your terminal emulator. If you don't want that, configure your terminal emulator to do something else.
    – romainl
    Commented Apr 26, 2021 at 8:10
  • Well, romainl, the terminal says the action of the right mouse button is "paste" (as opposed to "extend", "menu", or "enter"). Is there a way to change vim's settings so that the action of Shift+Insert (or paste) is to execute the characters as commands? I know it used to do that by default (as long as vim was in command mode when I did the paste) because I have many times created a command sequence, copied it, and repeatedly pasted it in to execute it.
    – Neo
    Commented Apr 26, 2021 at 22:47

1 Answer 1

3

Turns out it's called bracketed paste. To revert to the old behavior, use

:set t_BE=

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .