Always show the register list in vim

11

I'm getting the hang of using registers in Vim, but it would be really handy not to have to keep typing :reg to see where everything was. is it possible to set vim up so that the register panel is always visible?

Joe

Posted 2013-10-10T10:20:44.537

Reputation: 2 942

Answers

4

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.

Joe

Posted 2013-10-10T10:20:44.537

Reputation: 2 942

11

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>

Ingo Karkat

Posted 2013-10-10T10:20:44.537

Reputation: 19 513

It's a nice little remap (and I learned something about remap in the process, which is very nice, but I am willing/intending to lost the screen real-estate... of coruse, ideally it would be in a little tear-off window... – Joe – 2013-10-13T17:40:57.697

Vim doesn't support tear-off windows, but apart from that, I've outlined how you'd implement that. – Ingo Karkat – 2013-10-14T07:53:16.950

2

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

David

Posted 2013-10-10T10:20:44.537

Reputation: 21