Question

I would like to have some sort of auto completion for named registers.
If I try to access one (" or CTRL+r ...) a completion similar to the line completion (CTRL+l) should be opened. Some nice visualization of the unused/free register would be nice too.

Is there a nice solution for this?

Was it helpful?

Solution

Hooking into the built-in commands (like " and Ctrl+r) is difficult, because Vim then is in a special sub-mode where it waits for the register name. I use the following "" mapping (which normally is a no-op) to refresh my memory:

" ["x][N]""         List contents of the passed register / [N] named
"                   registers / all registers (that typically contain
"                   pasteable text).
nnoremap <silent> <expr> "" ':<C-u>registers ' . (v:register ==# '"' ? (v:count ? strpart('abcdefghijklmnopqrstuvwxyz', 0, v:count1) : '"0123456789abcdefghijklmnopqrstuvwxyz*+.') : v:register) . "<CR>"

OTHER TIPS

I recently created plugin https://github.com/imomaliev/registers.vim

Install it with your favourite plugin manager(like Plug)

Plug 'imomaliev/registers.vim'

Аnd after that you can do <C-x><C-r> in insert mode and completion menu with registers will be called.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top