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
  • 35,848
  • 27
  • 79
  • 88
chtenb
  • 13,449
  • 12
  • 67
  • 110

1 Answers1

10

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

:execute 'source '.fnameescape(myvar)
Anton Kovalenko
  • 20,203
  • 2
  • 35
  • 68