Improving usage of registers


I use registers regularly in my daily process of working in Vim. Practically everyone does, whether they realize it or not. If you simply yank and paste with yy and p in Vim, you are using a register, specifically the unnamed register.

One challenge I encounter is remembering the names of the various internal registers not to mention remembering what’s stored in them at any given point. To find out what’s stored in each register, simply use Vim’s :registers command, or :reg for short.

But I recently came across the Peekaboo plugin which improves the register experience. Peekaboo will display the registers and their corresponding stored values automatically whenever you use a register: with " and @ in normal mode and with <ctrl-r> in insert mode. It displays this data in a sidebar, with the registers conveniently labeled for their intent: special registers, numbered registers, and named registers. The list allows you to easily choose the register you want to paste from: Pressing " will open the sidebar, then you can glance at what’s available, press the desired register character, such as 4 for the 4th numbered register, then p to paste from that register.

Watch the demo below. I use Peekaboo to quickly view and choose a register to paste from. In our recent tip, Pasting multiple times, we explained how the 0 register contains the last thing yanked. In the demo, you can see this illustrated after I paste over the replacement line.

How useful was this tip?

Average rating 4.8 / 5. Vote count: 48

No votes so far! Be the first to rate this tip.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Written by

Andy Libby

34 Posts

Rider of bicycles. Writer of code. User of Vim.
View all posts

4 thoughts on “Improving usage of registers”

  1. while this is nice, I do prefer the posts that show how to use base vim to accomplish things, rather than installing yet another plugin.

    1. Good feedback, thanks! I agree. Whenever we mention plugins, we try to show the alternative in regular base Vim. So in this case, we mention :reg to show you your register contents and then talk about the plugin after.

  2. Wow, :registers is something I didn’t even realize I was missing. Already useful. Maybe I’ll graduate to the plugin eventually, but for now, thrilled with the built-in.

Comments are closed.