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!

1 Answer 1

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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