-
Notifications
You must be signed in to change notification settings - Fork 0
/
24_Function_Arguments.vim
62 lines (45 loc) · 983 Bytes
/
24_Function_Arguments.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
function DisplayName(name)
echom "Hello! My name is:"
echom a:name
endfunction
call DisplayName("Stone")
function UnscopedDisplayName(name)
echom "Hello! My name is:"
echom name
endfunction
"call UnscopedDisplayName("Your Name") "undefined var error
function Varg(...)
echom a:0
echom a:1
echom a:000
endfunction
call Varg("a","b")
function Varg2(foo,...)
echom a:foo
echom a:0
echom a:1
echom a:000
endfunction
call Varg2("a", "b", "c")
function Assign(foo)
let a:foo = "Nope"
echom a:foo
endfunction
"call Assign("test") "Cannot change read-only variable "a:foo"
function AssignGood(foo)
let foo_tmp = a:foo
let foo_tmp = "Yep"
echom foo_tmp
endfunction
call AssignGood("test")
" examples in :help local-variables
function Table(title, ...)
echohl Title
echo a:title
echohl None
echo a:0 . " items:"
for s in a:000
echon ' ' . s
endfor
endfunction
call Table("Table", "line1", "line2")