10

I'm using the latest version of vim 8.2.148 on the latest version of arch linux 5.5.6-arch1-1 with the latest version of Openbox window manager version 3.6.1.

I have written a document in vim and need to yank parts of it and paste them into a web form.

Is there a command in vim to yank to the system wide / openbox clipboard so that I can paste into the chromium web form?

Yank seems to work inside vim only.

1
  • 2
    Welcome to Vi/Vim SE. I'm sure I've seen answers here before that cover this. Did you try the Search box up top? If you found some but they were missing some critical detail please note that.
    – B Layer
    Mar 8, 2020 at 1:31

1 Answer 1

14

First get into an appropriate visual mode. v selects the standard visual mode, SHIFT-v selects visual-line mode, and CTRL-v selects visual block mode. Next, select the text that you want to select. Finally, "+y.

  • " means register.

  • + specifies the system clipboard register.

  • y is yank.

So "+y yanks into the system clipboard register.

more info on registers:

7
  • I has to install neovim to get this to work. My native vim install did not support copy to system wide clipboard.
    – Kes
    Mar 8, 2020 at 17:33
  • 1
    You might want to check your vimrc and plugins on your native vim install. Some sort of misconfiguration could be interfering. It should work out of the box. However, nvim is better anyway.
    – JMW
    Mar 8, 2020 at 18:12
  • tried this on a fresh install of Linux Mint 20.1 and doesn't work. No custom .vimrc. ¯\_(ツ)_/¯ Apr 28, 2021 at 19:08
  • 1
    vim-gtk package on ubuntu contains the +clipboard fyi
    – Goblinhack
    May 28, 2021 at 7:59
  • 1
    @Goblinhack I saw that + was not in the registers when using :reg and installing that thing solved it
    – Minsky
    Jan 8, 2022 at 12:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.