Imagine a situation, where you remember, that you want to re-use something you have deleted a while ago. Most likely the thing that has been deleted is stored in one of the numeric registers. Usually it's not a big deal to just type :reg and start looking through the list. However, I often find myself in a situation, where many of the registers are similar, and finding the register I want to use is difficult. Or it might be the case that I have yanked something to a permanent register but just can't remember which one it was. In these kind of situations I would find it quite useful to be able to search the registers: if I remember that the line I want to re-use contains the word function I would like be able get a list of just the registers containing that word.

Is this possible? Perhaps with a plugin I'm not aware of?

2 Answers 2


First, we need the list of all registers. It can be generated with:

let regs=split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/-"', '\zs')

Then, it can be filtered to keep only the register names that contain a given pattern

let pattern = 'function'
echo filter(copy(regs), 'match(getreg(v:val), pattern) >= 0')

This can be transformed to produce a result similar to :register

echo join(map(filter(copy(regs), 'match(getreg(v:val), pattern) >= 0'), '"~".v:val."   ".strtrans(getreg(v:val))[:&co-1]'), "\n")

(Unfortunately , it requires more work than just [:&co] to limit the number of characters printed on each line)

as a command, it becomes:

command! -nargs=1 Registers  
    \ echo join(map(
    \   filter(
    \      split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/-"', '\zs'), 
    \      'match(getreg(v:val), <q-args>) >= 0'), 
    \   '"~".v:val."   ".strtrans(getreg(v:val))[:&co-1]'), "\n")
  • 1
    Too bad, :filter /function/ :reg does not work yet. Commented Jul 19, 2018 at 15:23
  • @ChristianBrabandt How will it work? Because for instance :echo join(filter(split(execute('registers'), "\n"), 'match(v:val, "function")>=0'), "\n") and my other solution give different results. The solution in the answer matches on the whole register content, but this one from the comment matches only of what is displayed (which is trimmed to fit on &co characters). Commented Jul 19, 2018 at 15:36
  • @LucHermitte :filter does not actually filter what is displayed exactly, the matching is custom for each command. for example filter /99/ oldfiles matches files with 99 in their name, and ignores the numbers before the filenames
    – Mass
    Commented Jul 19, 2018 at 20:13
  • 1
    @LucHermitte currently support for :reg is not supported. Bug this question would be a good usecase. Commented Jul 20, 2018 at 8:56

The denite plugin can give you a list off all registers and you can type keys to narrow it down.

The relevant command is Denite register.

It has many more lists/sources where you can select one and expect a reasonable action to be taken (buffers, files, commands, colorschemes, help topics, ...)

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.