2014-02-28 32 views
2

下面是一个例子:a:arg在vimscript中的含义是什么?

function! Mynumber(arg) 
    echo line(".") . " " . a:arg 
endfunction 

1,3call Mynumber(getline(".")),它打印的行号,并且每个所述第一三线电流缓冲器中的。

+1

':h function-argument' – FDinoff

回答

4

变量的前缀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.