簡體   English   中英

vim腳本中的“。=”是什么意思?

[英]What does “.=” in vim scripts mean?

我經常看到對“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#')

代碼將選項卡號( i )和視winnrtabpagewinnr(i,'$')tabpagewinnr(i,'$') )添加到選項卡名稱,使其看起來像“1:2/4緩沖區名稱”。 從它的外觀來看, .=操作似乎是在向s添加內容。 但是,我不明白前兩行是做什么的。 任何幫助表示贊賞。

vim的在線 幫助是你的朋友:

:h .=

  :let {var} .= {expr1} Like ":let {var} = {var} . {expr1}". 

:h expr-.

  expr6 . expr6 .. String concatenation 

: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". 

一次一個:


let s .= '%' . i . 'T'

假設i = 9且s =“bleah”,s現在將是“bleah%9T”


let s .= (i == t ? '%1*' : '%2*')

這是來自C的熟悉的三元運算符。如果t == 9,那么s現在是“bleah%9T%1 *”。 如果t是什么,但 9,則S現在是“bleah%9T%2 *”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM