How do I remap key combinations with a free variable?
For example, let's say I want to be able to insert a single letter without leaving normal mode. I would want something like
nnoremap <leader>i[variable] i[variable]<Esc>
such that pressing
(this is a stupid example because it doesn't reduce the number of keystrokes)
EDIT: For a more practical example, consider a command that surrounds the current word with the pressed character, i.e.
nnoremap <leader>s[variable] viws[variable][variable]<Esc>P
At the moment I have such a command (and an equivalent for visual mode surroundings) for
(I also have extended commands that surround selections with two different characters, i.e.
<> upon pressing only the first of these. For these I can also imagine having the same command and simply looking up the closing surrounding letter as a function of the input opening character)
[variable]is the argument to the last command in your mapping... Such as
nnoremap <leader>i i_<Esc>r, where the last
r(to replace a single character) is pending and will consume the next character...