How do I use vim registers?

vehomzzz picture vehomzzz · Sep 30, 2009 · Viewed 277k times · Source

I only know of one instance using registers is via CtrlR* whereby I paste text from a clipboard.

What are other uses of registers? How to use them?

Everything you know about VI registers (let's focus on vi 7.2) -- share with us.

Answer

FModa3 picture FModa3 · Sep 30, 2009

Registers in Vim let you run actions or commands on text stored within them. To access a register, you type "a before a command, where a is the name of a register. If you want to copy the current line into register k, you can type

"kyy

Or you can append to a register by using a capital letter

"Kyy

You can then move through the document and paste it elsewhere using

"kp

To paste from system clipboard on Linux

"+p

To paste from system clipboard on Windows (or from "mouse highlight" clipboard on Linux)

"*p

To access all currently defined registers type

:reg