chtenb
chtenb

Reputation: 16184

How to dynamically source a script?

How can I source a vim script whose filename is contained in a variable?

Just like :source, except that the parameter isn't a string literal, but a variable name.

Upvotes: 4

Views: 2419

Answers (1)

Anton Kovalenko
Anton Kovalenko

Reputation: 21507

You can always use :execute to build a command dynamically:

:execute 'source '.fnameescape(myvar)

Upvotes: 10

Related Questions