vim - copying between registers

by Scott Saad - March 15, 2012

Many times while in Vim, I like to test out regular expressions that I may use somewhere else (outside editor, command line, etc). Once I get the expression working I’ve sometimes found myself having to retype it into wherever it is I actually plan to use it.

A waste of my mother scratchin’ time!

Vim makes heavy use of registers. I recently learned that there is even a register for the last search preformed (i.e. ‘/’). Could it be there is also a register for the clipboard?

The * register is the clipboard. Now how do I go about copying between these two registers?

For reference, I found a handy Q/A on Stack Overflow about this very thing. To copy the last search expression into the clipboard register one would:

:let @*=@/

Yes. That simple.

Oh Internet, I love thee.

Discussion, links, and tweets

I'm a software geek living and working in Boulder, Colorado. Follow me on Twitter; you'll dig my tweets if you're into that sort of thing.