10

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.

13

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

  • 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. – Sato Katsura Jul 6 '16 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 '16 at 16:29
  • Here's something trivial that breaks: :%g/text/ normal "Ayy – Sato Katsura Jul 6 '16 at 17:35
  • The plugin has been updated to use configurable prefix. github.com/junegunn/vim-peekaboo/pull/41 – Tommy A Jul 8 '16 at 12:20
6

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().

2

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.

  • What's the difference between :dis and :reg? I always use the former. – Philip Kearns Jun 28 '16 at 12:01
  • None: :help :dis -> :di[splay] [arg] Same as :registers. {not in Vi} – Boldewyn Jun 28 '16 at 12:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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