Try this...
:nnoremap <C-r><C-r> :reg<CR>:let regname = input("Register? ") \| exe 'norm "' . regname . 'p'<CR>
You'll see the :reg
output and then a prompt. At the prompt enter the register (#
, a
, @
, etc.) and hit Enter. The contents of the selected register will be p
asted right after the current position of the cursor.
This is adapted from an answer I gave to a similar question about acting on the output of the [I
command.
Fortunately, :reg
enters the same general "what now?" prompt as [I
does. That prompt allows :
as a response and that puts us on the regular command line without dismissing the previous command's output. From there it's just a matter of displaying a prompt and then building a :normal
command that pastes whatever register the user entered.
Update: Sounds like OP is interested in a variation that doesn't require hitting Enter. This should do it:
:nnoremap <C-r><C-r> :reg<CR>:echom "Register? "\|let n=nr2char(getchar())\|exe 'norm "'.n.'p'\|redraw<CR>
Besides using nr2char(getchar())
to get the register name I tacked a :redraw
onto the end to eliminate the Press Enter or type command to continue prompt that blocks immediate return to Normal mode.
(FYI it's also shortened/compressed a bit compared to the first one.)