interacting with
the "+" and/or "*" registers explicitly): >vim
set clipboard+=unnamedplus
See 'clipboard' for details and options.
*clipboard-tool*
The presence of a working clipboard tool implicitly enables the "+" and "*"
registers. Nvim supports these clipboard tools, in order of priority:
- |g:clipboard| : User override (if set to a dict or any string "name" below;
e.g. `g:clipboard="tmux"` forces tmux clipboard and skips auto-detection).
- "pbcopy" : pbcopy, pbpaste (macOS)
- "wl-copy" : wl-copy, wl-paste (if $WAYLAND_DISPLAY is set)
- "wayclip" : waycopy, waypaste (if $WAYLAND_DISPLAY is set)
- "xsel" : xsel (if $DISPLAY is set)
- "xclip" : xclip (if $DISPLAY is set)
- "lemonade" : lemonade (for SSH) https://github.com/pocke/lemonade
- "doitclient": doitclient (for SSH) https://www.chiark.greenend.org.uk/~sgtatham/doit/
- "win32yank" : *win32yank* (Windows)
- "putclip" : putclip, getclip (Windows) https://cygwin.com/packages/summary/cygutils.html
- "clip" : clip, powershell (Windows) https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/clip
- "termux" : termux (via termux-clipboard-set, termux-clipboard-set)
- "tmux" : tmux (if $TMUX is set)
- "osc52" : |clipboard-osc52| (if supported by your terminal)
*g:clipboard*
To configure a custom clipboard tool, set `g:clipboard` to a string name (from
the above |clipboard-tool| list), or dict (to explicitly specify the shell
commands or |lambda| functions).
If "cache_enabled" is |TRUE| then when a selection is copied Nvim will cache
the selection until the copy command process dies. When pasting, if the copy
process has not died the cached selection is applied.
The "copy" function stores a list of lines and the register type. The "paste"
function returns the clipboard as a `[lines, regtype]` list, where `lines` is
a list of lines and `regtype` is a register type conforming to |setreg()|.
Example: set to "osc52" to force OSC52, skipping auto-detection of terminal
support: >vim
let g:clipboard = 'osc52'
Example: set to "wayclip" to force waycopy/waypaste: >vim
let g:clipboard = 'wayclip'
Example: set to a dict which integrates the tmux clipboard: >vim
let g:clipboard = {
\ 'name': 'myClipboard',
\ 'copy': {
\ '+': ['tmux', 'load-buffer', '-'],
\ '*': ['tmux', 'load-buffer', '-'],
\ },
\ 'paste': {
\ '+': ['tmux', 'save-buffer', '-'],
\ '*': ['tmux', 'save-buffer', '-'],
\ },
\ 'cache_enabled': 1,
\ }
Example: set to a dict which uses g:foo as a fake clipboard: >vim
let g:clipboard = {
\ 'name': 'myClipboard',
\ 'copy': {
\ '+': {lines, regtype -> extend(g:, {'foo': [lines, regtype]}) },
\ '*': {lines, regtype -> extend(g:, {'foo': [lines, regtype]}) },
\ },
\ 'paste': {
\ '+': {-> get(g:, 'foo', [])},
\ '*': {-> get(g:, 'foo', [])},
\ },
\ }
<
*clipboard-wsl*
For Windows WSL, try this g:clipboard definition:
>vim
let g:clipboard = {
\ 'name': 'WslClipboard',
\ 'copy': {
\ '+': 'clip.exe',
\ '*': 'clip.exe',
\ },
\ 'paste': {
\ '+': 'powershell.exe -NoLogo -NoProfile -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
\ '*': 'powershell.exe -NoLogo -NoProfile -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
\ },
\ 'cache_enabled': 0,
\ }
<
*clipboard-osc52*
Nvim bundles a clipboard provider that allows copying to the system clipboard
using OSC 52, an "Operating System Command" control-sequence that causes the
terminal emulator to write to or read from the system clipboard.