vimautocompletevim-registers

Vim register completion


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?


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>"