4

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.

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
chtenb
  • 14,924
  • 14
  • 78
  • 116

1 Answers1

10

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

:execute 'source '.fnameescape(myvar)
Anton Kovalenko
  • 20,999
  • 2
  • 37
  • 69