If I copy to X11 (copy) clipboard in Vim using "+y
, I can only paste contents as long as Vim is open. The reason is as follows:
From Ubuntu Wiki: ClipboardPersistence:
The problem happens because Xorg takes a conservative approach to copying. It copies only a reference to the original data when the user performs a select or copy. It doesn't go and retrieve the actual data from the source program until the user requests a paste. It saves a lot of unneeded transfer of data this way, at the expense of having no way of retrieving data from a closed program that hasn't saved its clipboard somewhere else.
I.e. after exiting Vim, X11 cannot retrieve data from it anymore, since the reference is invalid.
How can I overcome this "limitation" of X11 to paste the X11 (copy) clipboard after Vim has exited, e.g. using a clipboard manager?
Ultimately, what I want is behavior similar to:
Freedesktop's ClipboardManager specification comes to the rescue. Gnome settings daemon, the component of Ubuntu that handles all copying and pasting by default, conforms by allowing applications to explicitly request to save their clipboard contents in a safe place. Applications conform by requesting a save before they exit. Everything gets squared away before a quit and we don't lose any data.
clipmenu
was recommended, but it's not available as a Debian package. Futhermore,autocutsel
didn't persisted the clipboard on exit using autocutsel -selection PRIMARY -fork
or autocutsel -selection CLIPBOARD -fork
.
clipmenu
compiled locally, and it works perfectly. Seems it (clipmenud
) monitors both the PRIMARY and CLIPBOARD selections for changes, saves them to files, afterwards it’s possible to overwrite both selections with a change. Can’t figure out how to overwrite only one selection with a change?clipmenu
I select an earlier selection, saved byclipmenud
to a file, which then becomes the current PRIMARY and CLIPBOARD selections