vim脚本中的".="是什么意思?

7 vim

我经常看到对"let s.='something'"形式变量的赋值.这是我一直在努力理解的vim脚本中的特定代码片段:

let s .= '%' . i . 'T'
let s .= (i == t ? '%1*' : '%2*')
let s .= ' '
let s .= i . ':'
let s .= winnr . '/' . tabpagewinnr(i,'$')
let s .= ' %*'
let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#')
Run Code Online (Sandbox Code Playgroud)

代码将选项卡号(i)和视口号(winnrof tabpagewinnr(i,'$'))添加到选项卡名称,使其看起来像"1:2/4缓冲区名称".从它的外观来看,.=操作似乎是附加东西s.但是,我不明白前两行是做什么的.任何帮助表示赞赏.

ax.*_*ax. 10

vim的在线 帮助是你的朋友:

:h .=

 :let {var} .= {expr1}    Like ":let {var} = {var} . {expr1}".
Run Code Online (Sandbox Code Playgroud)

:h expr-.

 expr6 .   expr6 ..   String concatenation
Run Code Online (Sandbox Code Playgroud)

:h expr1 (好吧 - 这有点难找):

 expr2 ? expr1 : expr1

 The expression before the '?' is evaluated to a number.  If it evaluates to TRUE, the result is the value of the expression between the '?' and ':', otherwise the result is the value of the expression after the ':'.
 Example:
   :echo lnum == 1 ? "top" : lnum

  Since the first expression is an "expr2", it cannot contain another ?:.  The
  other two expressions can, thus allow for recursive use of ?:.
  Example:
    :echo lnum == 1 ? "top" : lnum == 1000 ? "last" : lnum

  To keep this readable, using |line-continuation| is suggested:
    :echo lnum == 1
    :\  ? "top"
    :\  : lnum == 1000
    :\      ? "last"
    :\      : lnum

  You should always put a space before the ':', otherwise it can be mistaken for
  use in a variable such as "a:1".
Run Code Online (Sandbox Code Playgroud)