when using “pyfile s:pyscript” it seems vim doesn't interpret “s:pyscript” as a variable

泄露秘密 提交于 2019-12-23 02:51:01

问题


A vim-script file calls a python script through:

let s:pyscript = resolve(expand('<sfile>:p:h:h')) . '/pyscript/deploy.py'

echom "sourcing " . s:pyscript
pyfile s:pyscript

the echom-command shows me the expansion points to the correct file, but the following pyfile s:pyscript results in an error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
IOError: [Errno 2] file or directory not found: '&s:pyscript' 

Which let's me conclude, that everythin after pyfile is immediately considered "python" and vim doesn't evaluate the s:pyscript variable.

What's the way around it? Either in the python-script or the vim-"master" script is fine.


回答1:


Use :execute:

execute 'pyfile ' . s:pyscript


来源:https://stackoverflow.com/questions/21212385/when-using-pyfile-spyscript-it-seems-vim-doesnt-interpret-spyscript-as-a

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!