下面是一個例子:a:arg在vimscript中的含義是什麼?
function! Mynumber(arg)
echo line(".") . " " . a:arg
endfunction
當1,3call Mynumber(getline("."))
,它打印的行號,並且每個所述第一三線電流緩衝器中的。
下面是一個例子:a:arg在vimscript中的含義是什麼?
function! Mynumber(arg)
echo line(".") . " " . a:arg
endfunction
當1,3call Mynumber(getline("."))
,它打印的行號,並且每個所述第一三線電流緩衝器中的。
變量的前綴a:
表示該變量屬於它所在函數的參數列表(參數)。
也:help internal-variables
There are several name spaces for variables. Which one is to be used is
specified by what is prepended:
(nothing) In a function: local to a function; otherwise: global
buffer-variable b: Local to the current buffer.
window-variable w: Local to the current window.
tabpage-variable t: Local to the current tab page.
global-variable g: Global.
local-variable l: Local to a function.
script-variable s: Local to a :source'ed Vim script.
function-argument a: Function argument (only inside a function).
vim-variable v: Global, predefined by Vim.
請參閱「當你寫一個Vimscript中的函數,它始終需要加撥這些參數的參數:當您使用它們讓Vim知道他們在爭論範圍。 「 (強烈推薦閱讀):http://learnvimscriptthehardway.stevelosh.com/chapters/24.html
':h function-argument' – FDinoff