Search code examples
vimclipboard

Prevent Vim from clearing the clipboard on exit


When I open Vim from a terminal, copy some text to the system clipboard, and exit Vim, the system clipboard gets cleared.

How to keep the copied text in the clipboard?


Solution

  • Synthesizing answers from superuser, just add the following to your .vimrc

    autocmd VimLeave * call system("xsel -ib", getreg('+'))