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.

1 Answer 1

10

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

:execute 'source '.fnameescape(myvar)
Sign up to request clarification or add additional context in comments.

1 Comment

Ahem, escape() takes an additional argument and is the wrong one; you probably meant fnameescape().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.