2

I know that if I do:

:inoremap <expr> . InsertDot()

the result of InsertDot() will be inserted as {rhs} of the mapping.

I need to do the same but with the {lhs}, in order to be able to define some dynamic mappings that will take as key sequence what is defined in a var.

Is it possible? If so, how?

Thanks!

5

You could use the execute command. If your lhs is in the variable l:lhs you can do:

execute "inoremap <expr> " . l:lhs . " InsertDot()"

execute will expand the content of the variable and then execute the string obtained by the concatenation of the quoted string and the value of the variable.

See :h :execute for more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.