Reputation: 11
I use copy and paste a lot in vim, and I have "set clipboard=unnamed" to mirror the vim buffer to the cut/paste buffer; however, I've noticed when copying from the vim buffer, when pasting back into a vim command, it will submit the command (as if a CR or LF was being added to my Pastebin) but this doesn't happen if I use my mouse right click copy/paste (no additional LF/CR). For example I use visual block to select text, yy to copy, then :%s/ (to replace text) but when I paste it will submit it, but only if I use vim to copy the text the first place not X buffer. I really hate reaching for my mouse, please help! Also, I should note I'm on a mac, but I don't think it matters much, vim version 7.4
Upvotes: 0
Views: 160
Reputation: 11
brettanomyces as answered it completely actually, i've been playing with it for a little while, and when using visual block, I can use CTRL-R+ to paste into the buffer into the command field. If I want to copy an entire line I can use ^y$, so i don't get line-feeds, this works perfectly.
Upvotes: 0
Reputation: 7678
Its a bit difficult to understand what the issue you are having is but as I understand it you want to copy some text from a buffer and paste it into your command, without causing it to be executed right away.
What I think you want to be doing instead of using your mouse to paste the content into the command is to use <ctrl-r>
, see :help i_CTRL-R
, which will allow you to paste the content of the register into the command without using the mouse, and without interpreting the newlines (instead they will appear as ^M
).
E.g. if you type yy:%s/<CTRL-R>+
you should see :%s/LINE-YOU-YANKED^M
in the command.
Alternatively you can use a command that doesn't put a newline in the buffer like yy
does. Try y$
or ^y$
.
Upvotes: 1