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.
- Check if we have
+clipboard
on our version ofvim
- If you’re using bash on Windows or Ubuntu, and vim does not have
+clipboard
,sudo apt-get install vim-gnome -y
+clipboard
gets installedvim file
- Type:
:%y+
to copy all lines - 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!