16

I use the registers a lot for copy/pasting, but I always forgot in which register my content is.

Is there a way to display the registers before pasting?

Ideally it would leave the register on screen when selecting the one we want.

3 Answers 3

14

This peekaboo plugin is pretty good for for previewing registers. When you press " or @ in normal mode, or ctrl-r in insert mode, a split will open to show you the register contents.

Preview from the plugin repo:

peekaboo

4
  • This plugin would be a lot less obnoxious if the key bindings would be user-configurable. Binding to " and @ in normal mode breaks just about all macros that use registers. FWIW. Jul 6, 2016 at 6:32
  • Hmm, I'm not having issues with the recursive macros I tend to use, even with registers involved. The plugin disables itself when replaying macros with @. The README notes that non-recursive maps will cause problems. I agree that it'd be nice if it could be configured to just view the registers, though.
    – Tommy A
    Jul 6, 2016 at 16:29
  • Here's something trivial that breaks: :%g/text/ normal "Ayy Jul 6, 2016 at 17:35
  • The plugin has been updated to use configurable prefix. github.com/junegunn/vim-peekaboo/pull/41
    – Tommy A
    Jul 8, 2016 at 12:20
7

I made up this mapping to display the register list and select the one to be pasted:

nnoremap "p :reg <bar> exec 'normal! "'.input('>').'p'<CR>

This display the register list with :reg and execute the normal command

"Xp 

Where X is the result of input().

7

I would recommend using

:reg

It will show the contents of all registers (you can scroll through using j and k).

If you just want to show the contents of one register, you can go to command mode and type

: Ctrl + r

then the register, for example the x register

x

which will paste the contents of the register into the command line. You can then escape out of the command line after viewing your register.

3
  • What's the difference between :dis and :reg? I always use the former. Jun 28, 2016 at 12:01
  • None: :help :dis -> :di[splay] [arg] Same as :registers. {not in Vi}
    – Boldewyn
    Jun 28, 2016 at 12:31
  • 1
    Brilliant! This also works in Emacs' evil-mode, where it opens a special buffer where one can see the contents of all registers (and macros!).
    – ndrdm
    Aug 30, 2023 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.