简体   繁体   English

在vim中设置makeprg时如何使用变量?

[英]How to use variable when setting makeprg in vim?

I am creating a method called SetLaunchingComponent which is used to set the makeprg with the variable passed in.This is how the script look like now. 我正在创建一个名为SetLaunchingComponent的方法,该方法用于通过传入的变量来设置makeprg。这就是脚本现在的样子。

function! SetLaunchingComponent(path) 
    set makeprg=$path
endfunction

Obviously the function isn't working as i wished. 显然,该功能无法正常运行。 As vim resolve the path environment as the system variable but not a:path. 在vim中,将路径环境解析为系统变量,而不是a:path。 So what should i do? 所以我该怎么做?

要设置一个选项,您应该使用以下语法:

let &makeprg=a:path
command! -n=1 SL call SetLanuchingComponent(<arg>)

这将使您易于使用该功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM