In this tutorial, I used Cygwin on Windows 10 and Bash on Windows 10 to copy text from vim to the system clipboard for pasting.

  1. Check if we have +clipboard on our version of vim
  2. If you’re using bash on Windows or Ubuntu, and vim does not have +clipboard, sudo apt-get install vim-gnome -y
  3. +clipboard gets installed
  4. vim file
  5. Type: :%y+ to copy all lines
  6. Right click and paste, and you’ll see the lines you copied from vim

 

Check if we have +clipboard on our version of vim.

vim --version

Instead of -clipboard, we want +clipboard.

 

If you’re using bash or Ubuntu, and vim does not have +clipboard already:

sudo apt-get install vim-gnome -y

 

+clipboard gets installed.

vim --version

 

Open the file with vim and copy its contents to the clipboard.

vim file

Type:

:%y+

to yank all lines.

 

Now, you can right click and paste into a text editor.

I pasted the clipboard to an empty document in Sublime!