How to use clipboard on vim via Manjaro KDE?

vim --version | grep "clipboard"
-clipboard         +jumplist          +popupwin          +user_commands
+ex_extra          -mouse_jsbterm     -sun_workshop      -xterm_clipboard

I installed vim via pacman and it does not support clipboard, what should I install next?

The easiest way would be to install the gvim package, which has support for clipboard functionality. Your ~/.vimrc file will work for gvim also.
During the installation you’ll be asked to remove vim, since the two packages conflict with each other.

After installing gvim you’ll notice that vim --version | grep -i "clipboard" will mark clipboard and xterm_clipboard as present.

After that, you can use "+y to copy (while in Visual mode) from Vim to the clipboard and "+p for pasting to Vim from the clipboard.

To make it easier, you can create key bindings for copying/pasting to/from clipboard in your ~/.vimrc file. Something like that for example:

noremap <C-c> "+y
noremap <C-v> "+p

(you can use whatever keybindings you like better in your config file)

1 Like

I use neovim but I think it should work same in vim as well.

I have set clipboard+=unnamedplus in my init.vim, you should put it in your .vimrc

You need to install xclip for this to work.

Does “C” stand for “Ctrl” here?

noremap <C-c> "+y
noremap <C-v> "+p


Error detected while processing /home/firestar/.vimrc:
line   26:
E492: Not an editor command: clipboard+=unnamedplus
Press ENTER or type command to continue

I guess it doesn’t work in vim then

yes, it stands for control

This means that you didn’t set the configuration correctly in .vimrc (you probably forgot the set part).
The right way is adding this line:

set clipboard=unnamedplus

But this will only work if Vim is compiled with clipboard functionality, which is not the case in Arch/Manjaro, as you already know.

See here for more details:'clipboard'

Yes, it stands for Ctrl, but these were only examples. Make sure the keybindings you set are not used by any other operation in Vim.

1 Like

Press the “v” to select.
Press the “y” to copy.
Press the “p” to paste.

This might be of interest: AUR vim-clipboard.git pkgbuild

1 Like


1 Like

No worries!

If you are using native vim and create new file ~/.vimrc without editing, then it works with copy to KDE clipboard by pressing Ctrl + Shift + c . But it broke or disable highlight, syntax and other many features.

If you need syntax and highlight, the file .vimrc adds:

syntax on
colo elflord

But other many features are missing, not good idea.

Enable visual mouse to select text, but it broke copy to clipboard.

set mouse=a

It is bug or not?

1 Like

It is not bug, but set mouse=a turns off the clipboard.

If you want to copy text to the clipboard, you must disable visual mouse to select text:

set mouse=v


set mouse=r
  • Uninstall vim
  • Install gvim that supports clipboard.
  • Edit the file ~/.vimrc
"Import defaults.vim from /usr/share/vim/[VIM_VERSION]/
scriptencoding utf-8
if filereadable(expand('$VIMRUNTIME/defaults.vim'))
    unlet! g:skip_defaults_vim
    source $VIMRUNTIME/defaults.vim

"Config keyshorts for copy and paste
noremap <C-S-c> "+y
noremap <C-S-v> "+p
noremap y "+y
noremap p "+p

That works as my expectation.


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.