# Fix Vim Clipboard Plus Not Available in Terminal

You try to copy text from Vim to your system clipboard using "+y or "*y, but the yanked text does not appear in your system clipboard. Pasting from the system clipboard into Vim with "+p also fails. Vim reports:

bash
E354: Invalid register name: '+'

Or the yank appears to succeed but the clipboard is empty.

Understanding Vim Clipboard Registers

Vim has two clipboard registers: - "+ -- The system clipboard register (PRIMARY selection on X11) - "* -- The PRIMARY selection on X11, the clipboard on Windows/macOS

The availability of these registers depends on how Vim was compiled:

vim
:echo has('clipboard')

If this returns 0, your Vim was compiled without clipboard support.

Checking Clipboard Support

vim
:version | grep clipboard

You will see one of: - +clipboard -- Clipboard support is enabled - -clipboard -- Clipboard support is NOT available

If you see -clipboard, you need to install a version of Vim with clipboard support.

Installing Vim with Clipboard Support

Ubuntu/Debian

The default vim-tiny package lacks clipboard support. Install vim-gtk3 instead:

bash
sudo apt install vim-gtk3
sudo update-alternatives --set vim /usr/bin/vim.gtk3

Verify:

bash
vim --version | grep clipboard
# Should show: +clipboard

RHEL/CentOS

bash
sudo yum install vim-X11

macOS

The default system Vim may lack clipboard support. Use MacVim or Homebrew Vim:

bash
brew install vim

Ensure the Homebrew Vim is in your PATH before the system Vim:

bash
which vim
# Should be: /opt/homebrew/bin/vim (Apple Silicon) or /usr/local/bin/vim (Intel)

Terminal Without X11/Wayland

On a headless server or pure terminal (no GUI), the clipboard register requires an X11 or Wayland display. Check:

bash
echo $DISPLAY
echo $WAYLAND_DISPLAY

If both are empty, there is no display server running, and "+y will not work regardless of Vim's compilation flags.

Solution: Use tmux Clipboard Integration

If using tmux, you can integrate the system clipboard:

bash
# In ~/.tmux.conf
set-option -s set-clipboard on

Then in Vim, yank to the tmux buffer:

vim
" In ~/.vimrc
if exists('$TMUX')
    vnoremap <Leader>y y:call system("tmux load-buffer -", @")<CR>
    nnoremap <Leader>p :call setreg('"', system("tmux save-buffer -"))<CR>p
endif

Solution: Use OSC 52 Escape Sequence

Modern terminals support the OSC 52 escape sequence for clipboard access, which works over SSH:

```vim " In ~/.vimrc if !has('clipboard') function! CopyToClipboard(text) call system("printf '\033]52;c;' . a:text . '\007'") endfunction

vnoremap <Leader>y y:call CopyToClipboard(@")<CR> endif ```

This works in iTerm2, Alacritty, and Kitty terminals, even over SSH connections.

Neovim Clipboard Integration

Neovim handles clipboard differently. It requires an external provider:

bash
# Check clipboard provider
:checkhealth provider

Install a clipboard provider:

```bash # For X11 sudo apt install xclip # or sudo apt install xsel

# For Wayland sudo apt install wl-clipboard ```

Neovim automatically detects these providers. No additional configuration is needed.

Testing Clipboard Functionality

After fixing the clipboard setup:

```vim " Yank a line to the system clipboard "+yy

" Paste from the system clipboard "+p ```

Test from the command line:

bash
echo "test from vim" | xclip -selection clipboard
# Then try pasting in another application

If this works but Vim's "+y does not, the issue is Vim-specific. If this does not work, the issue is with the system clipboard tool (xclip, wl-clipboard, etc.).