How do I fix this copy problem?
Let's say you're browsing this page and you see the following piece of code:
_trackEvent(category, action, opt_label, opt_value, opt_noninteraction)
Double click to select the whole string, copy it and then paste it between the double quotes here in Vim:
<div onClick=""></div>
Well, instead of this:
<div onClick="_trackEvent(category, action, opt_label, opt_value, opt_noninteraction)"></div>
This is what I get when I do this:
_trackEvent(category, action, opt_label, opt_value, opt_noninteraction)
<div onClick=""></div>
And that's pretty annoying. This is due to the line break endings pasted by OS X into the clipboard. How can I tell Vim to ignore final line breaks when working with one liner?
Since you copied the whole line (with a terminating newline) Vim uses linewise paste, i.e. the text is not inserted at the cursor position, but on a separate line above / below the current one. With <C-R>*
out of insert mode you can avoid this, but it will still insert a trailing newline.
My UnconditionalPaste plugin has a mapping gcp
that inserts case always in character mode. (And a few related mappings for other modes and special pastes.) With it, you just position the cursor on the first / second "
and do "*gcp
/ "*gcp
.
source to share