Determinant
Determinant

Reputation: 4056

How to use variables in vim command-like syntax?

I want to write a function that can map a key to another function.

But I failed to insert the variables into map command:

map a:key :! a:action (in which a:key may be <F9>, <C-F9> and so on)

How to achieve this in vim command-like sentences?

Upvotes: 3

Views: 1575

Answers (1)

Randy Morris
Randy Morris

Reputation: 40947

If I understand your question correctly, you're looking for execute.

:execute "map " . a:key . " :!" . a:action

See :help :execute for more information.

Upvotes: 5

Related Questions