如何动态源脚本?

Chi*_*nke 3 vim

如何获取文件名包含在变量中的vim脚本?

就像:source,除了参数不是字符串文字,而是变量名.

Ant*_*nko 10

您始终可以使用:execute动态构建命令:

:execute 'source '.fnameescape(myvar)
Run Code Online (Sandbox Code Playgroud)

  • 嗯,`escape()`需要一个额外的参数而且是错误的; 你可能意味着`fnameescape()`. (2认同)