Last updated

Using multiple clipboards in Vim

On of the first things you learn when using Vim activly is that when you delete something using x or dd that content is actually cut and put on a clipboard. Later you can retrieve that content using the p or P commanands.

One thing that makes Vim more awesome than let’s say, uhm TextMate, is that it actually has more than one clipboard! Yeah! In fact, in Vim terminology those clipboards are called registers. ~

To view your current registers type :reg. You’ll notice that every register is prefixed with the symbol ".

How do you use these things? Let’s say you want to copy a line into a specific register: "kyy will yank the current line into register "k. If you later want to paste register "k you can do this: "kp. Easy, huh?

The beauty of registers is that they keep around until you explicitly copy something else into them. The normal clipboard or paste buffer is replaced everytime you cut or copy something, registers are not affected unless you specify to use them.

Now, go on, code more productively.

Tags: vi vim