Passing register name in mapping to an ex command
vim
Solution
Ah, I figured it out.
The trick is to use `<expr>` in the mapping.
So, for my example, the answer is:
nnoremap <expr> <leader>p ':put ' . v:register . '<CR>'
Check `:h map-expression` and `:h v:register` for more info.
Problem
Suppose I want to create a map in vim that will call an ex command as part of its work. And suppose that the ex command takes a register name as input. Here is a toy example: ``` nmap <leader>p :put x ``` The problem there is that the 'x' register will always be used. But when typing, I want to be able to write: ``` "a<leader>p ``` To use the 'a' register, or: ``` "b<leader>p ``` to use the 'b' register. Is there a way that I can pass the 'current normal-mode register' along to the 'ex' command?