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
"*
: (see:h unnamed
), the PRIMARY SELECTION"+
: (see:h unnamedplus
), the CLIPBOARD SELECTION- There’s also a lot of other registers which are historical and exotic IMHO
Neovim config example:
Copying to the PRIMARY selection:
-- 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"
Copying to CLIPBOARD is 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')
Note that the usual mappings for Ctrl+Shift+c (or Cmd+c) should work fine on terminals.