# 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:
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:
:echo has('clipboard')If this returns 0, your Vim was compiled without clipboard support.
Checking Clipboard Support
:version | grep clipboardYou 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:
sudo apt install vim-gtk3
sudo update-alternatives --set vim /usr/bin/vim.gtk3Verify:
vim --version | grep clipboard
# Should show: +clipboardRHEL/CentOS
sudo yum install vim-X11macOS
The default system Vim may lack clipboard support. Use MacVim or Homebrew Vim:
brew install vimEnsure the Homebrew Vim is in your PATH before the system Vim:
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:
echo $DISPLAY
echo $WAYLAND_DISPLAYIf 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:
# In ~/.tmux.conf
set-option -s set-clipboard onThen in Vim, yank to the tmux buffer:
" 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
endifSolution: 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:
# Check clipboard provider
:checkhealth providerInstall 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:
echo "test from vim" | xclip -selection clipboard
# Then try pasting in another applicationIf 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.).