Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to dynamically source a script?

Tags:

vim

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.

like image 462
chtenb Avatar asked Dec 26 '22 10:12

chtenb


1 Answers

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

:execute 'source '.fnameescape(myvar)
like image 64
Anton Kovalenko Avatar answered Jan 28 '23 11:01

Anton Kovalenko