1

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"
Sergey Potapov
  • 3,819
  • 3
  • 27
  • 46

2 Answers2

2

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')
Kent
  • 189,393
  • 32
  • 233
  • 301
  • I don't know what I was thinking when I posted it, I wrote `let a = echo maparg(...)` :-/ fixed.. – Kent Apr 25 '13 at 23:24
1

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.

Jim Stewart
  • 16,964
  • 5
  • 69
  • 89