Thursday, 31 December 2015

Copy paste in terminal via system clipboard in VIM in Fedora 23

The trouble

When you edit a file via vim editor in Fedora 23, then sadly by default you don't have access to the system clipboard. It means that you are not able to copy some text in the editor and then paste it for example to the browser or vice versa.

Luckily this issue has an easy solution.

Test if you need to fix it or not

To test if your vim supports x11 sytem clipboard run
vim --version
I expect that you will see -xterm_clipboard.  Our goal is to make it +xterm_clipboard.

Solution (Redhat/CentOS/Fedora)

sudo dnf install vim-X11
After that you will be able to use vimx command to start vim with xterm_clipboard support.
Try this:
vimx --version
Now you should see the desired +xterm_clipboard.

Test the result

To test it, just open a file in vim, select a text and then go different application where you can paste the text and hit mouse middle button. The selected text should be pasted there.

Tip'n tricks

As an improvement you can add an alias to your .bashrc file to use vimx even when vim command is started. Add this one line to your .bashrc file:
alias vim="vimx"

If you want to find out more about vim and system clipboard check the referred link below.

Source


No comments:

Post a Comment