Question

Let's say I have the next mapping:

imap a AAA
vmap b BBB

I need a way to get value of mappings. The next is not suitable for me, because I need to operate by returned mapped values:

imap a
vmap b

I'm looking for for something like these functions:

let a = getimap("a")   => a = "AAA"
let b = getvmap("b")   => b = "BBB"
Was it helpful?

Solution

the maparg() function is what you are looking for. :h maparg( to see detail.

to your question, if you have those two mapping, you could:

let a =  maparg('a','i')
let b =  maparg('b','v')

OTHER TIPS

You can use maparg() to do this, like so:

let a = maparg("a")

You can also specify the mode if you only want mappings for one mode, and it will optionally populate a dictionary with every detail of the mapping (things like <silent>, etc.). See :h maparg() for all the details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top