There’s multiple selections: ¶
- PRIMARY: is the old-school Unix one; select text to copy it. Middle-click to paste it. Three-finger tap on a touchpad also pastes it.
- CLIPBOARD: the well-known ctrl-c and ctrl-v (or Super+c).
- SECONDARY: historical, irrelevant, don’t worry about this one.
Vim (& derivates) ¶
Vim has registers. They are accessed by prefixing "X
, where X
is a register
name. These extend the ones above:
"-
:/dev/null
"*
: the PRIMARY SELECTION"+
: the CLIPBOARD SELECTION- There’s also a lot of other registers which are historical and exotic IMHO
Neovim config example: ¶
-- Copy to PRIMARY selection on mouse selection.
vim.keymap.set("v", "<LeftRelease>", '"*ygv')
-- Yank (copy) to PRIMARY selection by default (e.g.: with `yy`).
vim.opt.clipboard = "unnamed"
Also possible, but confusing in terminals:
-- Copy to CLIPBOARD selection with ctrl+c.
vim.keymap.set("v", "<C-c>", '"+ygv')
-- Paste from CLIPBOARD selection with ctrl+v.
vim.keymap.set("v", "<C-v>", '"+p')