If I copy text into the xterm clipboard from vim, it is cleared when I exit vim.
How do I prevent this?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
It’s fairly simple:
See this page for more information and options.
I don't have a good answer, and I don't have access at the moment to a system running X to experiment with, but this topic is discussed in the Vim reference manual here:
You didn't say how you copied text to the clipboard, but if you used the
* register, it might help to use the
+ register instead.
Try selecting while holding down shift instead. This (usually) tells your terminal emulator to directly copy text instead of sending the mouse events to Vim. Exiting Vim after doing it this way should not destroy the contents of the copy buffer, and a middle-click in another application should paste the selected text.
This will not help you with gVim. However, you note you use the + register, which means you should be accessing the clipboard, which is not destroyed on exit of the application that last "wrote" to it. This register is not pasted using middle-click with the mouse. Either use control-v (for applications that support pasting from the clipboard with that hot key) or right-click and select paste.