0
對於看起來像這樣一個簡單的問題,我很抱歉。Vimscript:在函數調用之前將變量解析爲值
我有一個示例命令定義如下:
command! -nargs=+ Exmpl call Example(<f-args>)
function! Example(name)
echo a:name
endfunc
這是如下調用:
Exmpl 'hello'
,但它似乎從字面上解釋,而不解析給定的參數。所以:
let hello = 'world'
Exmpl hello
不按預期打印world
。
這顯然是明顯的,我在the literature找不到。我已經嘗試添加各種轉義字符,如&
,但隨後的參數始終被視爲裸露的單詞。
如何在自定義Vim命令中使用變量?
你可以用':debug',看看什麼是真正執行 - >':調試Exmpl hello' +'s' + Enter +'s' + Enter。 .. –