Always show the register list in vim

The output of :reg is fleeting, you'd have to capture it (with :redir), and show it in a scratch buffer, and then find triggers to regularly update it. Possible, but difficult, and I'd permanently rob you of valuable screen real estate.

Alternative

Instead, I have a little shortcut to quickly bring up the contents of the most important ones. Because "" is the same as leaving off the register specification, this is easy to type (especially after the first ", when I start thinking: "Okay, which register do I want?", I can just type another ", and get this handy help), and it doesn't override any built-in commands.

" List contents of all registers (that typically contain pasteable text).
nnoremap <silent> "" :registers "0123456789abcdefghijklmnopqrstuvwxyz*+.<CR>

It turns out that the answer is outside vim.

vim stores it's registers in the .viminfo file (normally in the root) - so we really just need to watch it for changes.

A very simple way is the 'watch command' with a bit of command line fudging:

watch "cat .viminfo | grep -A 1 '\"[0-9a-z]'"

This prints out the current state of the vim registers and can be running in an entirely different window.

The slight drawback is that vim normally only saves it's registers to viminfo on file exit, but you can force the saving with the command ':wv'. Mapping this to a spare key gives you one touch updating of the register view.


While also searching for an alternative to typing :reg I found this plugin:

https://github.com/junegunn/vim-peekaboo

It displays and lets you choose registers when you type " and @ in normal mode and CTRL-r in insert mode.

I found it here: https://github.com/junegunn/fzf.vim/issues/10

Tags:

Vim