Glam Prestige Journal

Bright entertainment trends with youth appeal.

I am trying copy text in vim and then i use the *y, but pasting it into a browser does not work. I am using ubuntu with i3 tiling manager. Can someone help with this?

4 Answers

Answer for Ubuntu 20

You need to make sure clipboard is activated (which is probably not the case).

Run :vim --version | grep 'clipboard'

if you get "-clipboard" then you would have to install vim again with the "clipboard" functionality.

You can do it it by installing "vim-gtk3" or "gvim".

Solution

sudo apt-get install vim-gtk3 -y

With that, you will be able to copy into clipboard with typing (including the plus) "+y

1

Pressing y from visual mode yanks (copies) text into vim's special unnamed register which is not accessible from outside vim. To copy text to the system clipboard, use "+y. The " allows you to specify the register, + is the register that represents the system clipboard, and you already know what y does.

Alternatively, to tell vim to use the + register as the default register, put set clipboard=unnamedplus in your .vimrc.

highlight + y is a vim-specific yank command and likely won't work outside vim.

Use:

highlight text in vim with mouse/touchpad
<ctrl> c (or right click/copy)
select destination in new window
<ctrl> v (or right click/paste)

Works lots of other places as well.

If you want to leave the content of the register on system clipboard even AFTER closing the vim, then you can use xsel (sudo apt-get install xsel) and add the following line to the .vimrc:

autocmd VimLeave * call system("xsel -ib", getreg('+'))

[works on Ubuntu 20.04 as well]

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy