You are not logged in.
Hi. I can't seem to be able to copy and paste from vim to the same terminal, meaning: I write something to vim, then "+Y the line I wrote. Then I close vim and try to paste the copied text to terminal but it doesn't work. The terminal I use is st and I have the shortcut alt+v enabled to paste.
It works if I copy text from a browser or from another terminal window that has vim open, but I can't do it from the same one. Any ideas on why?
I should mention that I use VIM and have gvim installed for the clipboard functionality.
The only thing I could find on the net about this was: https://stackoverflow.com/questions/511 … e-terminal which wasn't very helpful.
Last edited by kibartas (2019-09-24 14:37:18)
Offline
Hello.
I don't know much. And no experience with st.
Does mouse middle button work to paste?
Last edited by Alber (2019-09-18 15:28:04)
Because not all of us are native English speakers, try no to use slang or abbreviations, thank you.
Offline
Does it work if you keep vim open?
Offline
I think gvim clears the buffer on exit, but you can use it like this:
"*yy
:sh
shift+insert
#When done press ctrl+d to return to vimOffline
Hello.
I don't know much. And no experience with st.
Does mouse middle button work to paste?
Sorry, for late reply. I use alt+v to paste, middle button doesn't have that functionality set to it.
Offline
Does it work if you keep vim open?
The exact problem is, I write a command to vim, then I copy it, close vim and try to paste it into shell, but it doesn't work
Offline
I think gvim clears the buffer on exit, but you can use it like this:
"*yy :sh shift+insert #When done press ctrl+d to return to vim
I guess that works. I mean, it works if I do "+yy, not with "*yy. It's still strange how I can paste it into anywhere EXCEPT the same terminal window.
Offline
What is "+Y supposed to do? That's not a default binding for anything.
Which buffer is it supposed to copy to?
What buffer have you configured st to paste with alt+v?
Use `xsel` and `xsel -b` after exiting vim to check the contents of the primary and clipboard buffers - is the text you 'copied' in either of them? Which one?
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
What is "+Y supposed to do? That's not a default binding for anything.
Which buffer is it supposed to copy to?
What buffer have you configured st to paste with alt+v?
Use `xsel` and `xsel -b` after exiting vim to check the contents of the primary and clipboard buffers - is the text you 'copied' in either of them? Which one?
Well, Y in VIM copies the line. "+ is the register to which it copies to and this is linked with CLIPBOARD.
From VIM Help pages:
There are three documented X selections: PRIMARY (which is expected to
represent the current visual selection - as in Vim's Visual mode), SECONDARY
(which is ill-defined) and CLIPBOARD (which is expected to be used for
cut, copy and paste operations).
Of these three, Vim uses PRIMARY when reading and writing the "* register
(hence when the X11 selections are available, Vim sets a default value for
|'clipboard'| of "autoselect"), and CLIPBOARD when reading and writing the "+
register. Vim does not access the SECONDARY selection.I have configured alt+v to paste from CLIPBOARD.
Okay, so I have figured something out. I think I may have misled myself and others on this one. Actually, when copying to the "+ register aka to CLIPBOARD, it gets wiped after I close vim.
When copying to "* register it lingers after I close vim. But it's pretty much useless, because it's not clipboard and I don't really know what to do with it.
xsel and xsel -b doesn't return anything.
Anyway, I have actually found this article on stackoverflow just now: https://stackoverflow.com/questions/645 … rd-on-exit
VIM clears clipboard after closing, but there is a workaround that's detailed in the page.
I'd say this is solved, thanks everybody.
Offline
autocmd VimLeave * call system("xsel -ib", getreg('+'))In case the link ever becomes unavailable. This is actually neat. Thanks for the follow up!
Offline