整数
16进制0x开头,8进制0开头,2进制0b开头。例如:
0x1f = 017 = 0b11111 = 15
变量
变量类型
s:name 脚本本地变量
b:name Buffer本地变量
w:name Window本地变量
g:name 全局变量
v:name Vim预定义变量
a:name 在函数内部,表示参数
变量释放
unlet {variable}
变量赋值
let {variable} = {expression}
条件判断
if
if {condition}
{statements}
endif
if-else
if {condition}
{statements}
else
{statements}
endif
if-elif
if {condition}
{statements}
elseif {condition}
{statements}
endif
循环
while
while {condition}
{statements}
endwhile
函数
function {name}({var1}, {var2}, ...)
{body}
endfunction
表达式(expression)
|expr1| expr2
expr2 ? expr1 : expr1 if-then-else
|expr2| expr3
expr3 || expr3 ... logical OR
|expr3| expr4
expr4 && expr4 ... logical AND
|expr4| expr5
expr5 == expr5 equal
expr5 != expr5 not equal
expr5 > expr5 greater than
expr5 >= expr5 greater than or equal
expr5 < expr5 smaller than
expr5 <= expr5 smaller than or equal
expr5 =~ expr5 regexp matches
expr5 !~ expr5 regexp doesn't match
expr5 ==? expr5 equal, ignoring case
expr5 ==# expr5 equal, match case
etc. As above, append ? for ignoring case, # for
matching case
expr5 is expr5 same |List|, |Dictionary| or |Blob| instance
expr5 isnot expr5 different |List|, |Dictionary| or |Blob|
instance
|expr5| expr6
expr6 + expr6 ... number addition, list or blob concatenation
expr6 - expr6 ... number subtraction
expr6 . expr6 ... string concatenation
expr6 .. expr6 ... string concatenation
|expr6| expr7
expr7 * expr7 ... number multiplication
expr7 / expr7 ... number division
expr7 % expr7 ... number modulo
|expr7| expr8
! expr7 logical NOT
- expr7 unary minus
+ expr7 unary plus
|expr8| expr9
expr8[expr1] byte of a String or item of a |List|
expr8[expr1 : expr1] substring of a String or sublist of a |List|
expr8.name entry in a |Dictionary|
expr8(expr1, ...) function call with |Funcref| variable
expr8->name(expr1, ...) |method| call
|expr9| number number constant
"string" string constant, backslash is special
'string' string constant, ' is doubled
[expr1, ...] |List|
{expr1: expr1, ...} |Dictionary|
#{key: expr1, ...} |Dictionary|
&option option value
(expr1) nested expression
variable internal variable
va{ria}ble internal variable with curly braces
$VAR environment variable
@r contents of register 'r'
function(expr1, ...) function call
func{ti}on(expr1, ...) function call with curly braces
{args -> expr1} lambda expression
网友评论