Today I Learned

hashrocket A Hashrocket project

Breezy copy to system clipboard in Vim

When it's time to get text processed in Vim out of your editor and onto a shiny blog post many Vim Warriors reach for the awkward "copy to system register" keyboard chord.

"*y[motion]

Worse is trying to copy the whole file:

gg"*yG

This feat of keyboard heroism has crushed many heroes and inflicted countless RSI wounds.

It's time to slay the dragon 🐲 by adding these to your .vimrc:

" copy to system clipboard
map gy "*y
" copy whole file to system clipboard
nmap gY gg"*yG
See More #vim TILs
Every developer at Hashrocket is a Vim expert. Check out our development environment, Dotmatrix, and if you are in Chicago, come to the Vim Chicago Meetup hosted at our Chicago office.