Clipboard
Rune copies and pastes through your operating system's clipboard by
default, so text you yank in the editor is available to other
applications and vice versa. This is controlled by the top-level
clipboard setting, which defaults to "system":
- config.yaml
- config.star
clipboard: "system" # or "memory"
"clipboard": "system", # or "memory"
How the system clipboard works
Rune talks to the platform clipboard through the standard system utilities. What it needs depends on your operating system:
| Platform | What Rune uses |
|---|---|
| macOS | pbcopy and pbpaste (ship with macOS) |
| Linux (Wayland) | wl-copy and wl-paste from wl-clipboard |
| Linux (X11) | xclip, or xsel |
On macOS the system clipboard works out of the box. On Linux Rune
shells out to one of the utilities above, so at least one must be
installed and on your PATH.
On a Wayland session Rune prefers wl-clipboard; on X11 it uses
xclip and falls back to xsel. Install whichever matches your
session, for example:
# Debian/Ubuntu, Wayland
sudo apt install wl-clipboard
# Debian/Ubuntu, X11
sudo apt install xclip # or: sudo apt install xsel
When the system clipboard is unavailable
If none of the expected utilities are present (a common case on a
headless or freshly installed Linux box), Rune cannot reach the system
clipboard. When that happens Rune keeps copy and paste working through
an internal in-memory clipboard so you are never stuck, and it shows a
system clipboard: … warning so you know the text did not leave Rune.
The fix is to install one of the utilities listed above for your platform.
Suppressing the warnings with memory
If you cannot or do not want to install a clipboard utility, set the
clipboard mode to "memory":
- config.yaml
- config.star
clipboard: "memory"
"clipboard": "memory",
In memory mode Rune uses an in-memory clipboard that lives entirely
inside the editor. Copy and paste work between Rune's own buffers and
registers, but the contents never cross the boundary to other
applications. Because Rune never touches the system clipboard in this
mode, the system clipboard: … warnings are suppressed.
The clipboard setting lives alongside the rest of your editor
configuration; see Config for where the file lives and
how to edit it.
Highlighting in the terminal
Dragging across text in a terminal highlights it and copies it to the clipboard, as do double-clicking a word and triple-clicking a line. A highlight starts only once the pointer leaves the cell you pressed, so a click (for example to focus the window) does not replace what you copied before.
When the program running in the terminal tracks the mouse, as vim does
with set mouse=a, clicks and drags go to that program instead and the
terminal does not highlight or copy. Use the program's own copy command,
such as yanking to the + register in vim.
Programs in the terminal
A program running in a terminal can set the clipboard itself through the OSC 52 escape sequence, which is how tmux, vim and similar tools copy from inside a terminal, including over SSH. The same sequence can also ask the terminal for the clipboard contents.
Both are controlled by terminal.clipboard:
- config.yaml
- config.star
terminal:
clipboard:
write: true # programs may set the clipboard
read: false # programs may read the clipboard
config["terminal"]["clipboard"] = {
"write": True, # programs may set the clipboard
"read": False, # programs may read the clipboard
}
Writing is on by default. Reading is off by default: anything whose
output reaches a terminal can send the sequence, such as a file you
cat, a build log or a command on a remote host, and a read hands it
whatever you last copied, which may be a password or a token. Turn it
on only if a tool you trust needs it, and bear in mind that writing
still lets such output replace what you were about to paste.
Programs that ask the terminal whether it accepts OSC 52 (the Ms
capability, queried with XTGETTCAP) are told so while writing is
allowed. Neovim 0.11 asks on startup and, when it finds no clipboard
tool of its own, as is common on a remote host, copies through OSC 52
without any configuration. With writing off, the terminal reports no
such capability and Neovim keeps its registers to itself.
See also
- Vim editor: registers and the
+system clipboard register - Standard editor: copy, cut, paste, and paste-history keys
- Config