If you have asked yourself “how to enable clipboard on Vim?” or “is it possible to access the system clipboard on Vim?“, the answer is: yes. This is how you can do it.
Note: in this example I’m using FreeBSD, but the principle is the same in other *nixes.
First, you need to get sure that you installed Vim package was compiled with xterm_clipboard compatibility. If instead of +xterm_clipboard you see -xterm_clipboard, your Vim package was not compiled with clipboard support.
$ vim --version | grep -i clipboard +clipboard +keymap +printer +vertsplit +eval -mouse_jsbterm -sun_workshop +xterm_clipboard
If this happens to be your case, then you should install the vim-x11-* package, or in my case (as I was interested in have GVim installed), the vim-gtk3-* package.
$ sudo pkg install vim-gtk3-9.0.0016
Now you should have access to the desktop clipboard.
Also, If you’re diving deeper into Vim, Practical Vim by Drew Neil covers everything from basic editing to advanced integration with your system clipboard, registers, and shell workflows.
Once you’ve got Vim’s clipboard working, the next step for many FreeBSD developers is setting up a local web stack. I walk through installing Apache and PHP-FPM on FreeBSD in another post—useful if you’re building or debugging PHP apps locally.
