I'm using Linux system. Two vims are opened in two terminals. Now I'd like to copy text from A to B. One way to do so is to select text in A, use mouse to copy, then switch to B, in the insert mode, command <c-r>+
will paste the text.
Is there anyway to perform it without using mouse? like "+yy
in A, when switch to B, o<c-r>+
? I explored couple of combinations in vain. And I searched for "copy across terminals", but find nothing.
user @statox suggests one solution using visual mode, i.e. v$"+y
in A, when switch to B, o<c-r>+
.
Is there any simple way that can copy the text in A without entering into v mode? Admittedly entering into v-mode does not involve too many key strikes, just wonder if there is better way. Eg. if the cursor is at the middle of a line, yy
copies the whole line (to register "
), while 0v$y
does the same thing with extra key stroke.
Or, my question can be reduced to if there is any way with fewer key strokes than 0v$"+y
for copy such that I can use <alt-tab>o<c-r>+
to paste.
"+y
and in the other vim instance put the clipboard register"+p
. Or duplicate of this?y
with a motion (:help motion.txt
) or an object (:help object-select
). If you yank and paste across Vim instances often, you may find that settingclipboard
to includeunnamed
orunnamedplus
useful. See:help 'clipboard'
. Then copying between instances should just work.0v$
is the same asV
. And it's easy to make a mapping for"+y
::nnoremap <Leader>y "+y
. So that reduces it toV\y
.V"+y
, 4 keystrokes.