Reputation: 4467
For quick execution of some commands I want to type them somewhere, then paste them into vim for execution. A while (some years or 10 years ago) this worked. Nowadays, vim enters insert mode and my commands get inserted into my file. I know that I can have macros for that, but for quick repetition of some commands this was very useful. Couldnt find anything about it, coz when asking for vim and paste only answers related to :set paste etc show up. Example of pasted text:
/foo
yy?bar
p/foo
j
Should, when pasted in command mode, search for the next foo, yank the line, search backwards for next bar, then paste the yanked foo-line, then go behind that foo-line. Again, to make it clear: I dont want to know about workarounds (makros, scripts, and so on), I want to know how to disable (temporarily) vim from distinguishing between text typed with keyboard and text pasted.
Upvotes: 3
Views: 607
Reputation: 7846
I had this same problem... I have LARGE files of vim commands that I use to bulk reformatting hundreds of plain text files. That is I would: paste commands, next file, paste commands, next file, and in so doing edit hundreds of files, with the given set of vim commands, in just a minute or so...
Then it all suddenly stopped working because Bracketed Paste mode was added... (part of patch 8.0.0238 I believe).
However I still liked the added ability to paste text when in insert mode, without vim auto-indent making a mess of the inserted text, so did not want to lose that either...
My solution, was to disable paste while in normal or command modes, while leaving brackets paste as in for insert mode...
nmap <PasteStart> <NOP>
nmap <PasteEnd> <NOP>
cmap <PasteStart> <NOP>
cmap <PasteEnd> <NOP>
Upvotes: 1
Reputation: 23556
If your Vim has been compiled with clipboard support then you can just leave 't_BE'
as is and instead execute clipboard as a register via @*
or @+
which will probably be more "idiomatic" way to handle such use case.
For more informations see :h @
.
Upvotes: 2
Reputation: 1813
This is the result of "bracketed paste mode". See :help xterm-bracketed-paste
.
Disable "bracketed paste mode" by clearing 't_BE'
:
set t_BE=
Upvotes: 4