UPDATE:從:help synID()
(見例子):
synID({line}, {col}, {trans}) *synID()*
The result is a Number, which is the syntax ID at the position
{line} and {col} in the current window.
The syntax ID can be used with |synIDattr()| and
|synIDtrans()| to obtain syntax information about text.
{col} is 1 for the leftmost column, {line} is 1 for the first
line.
When {trans} is non-zero, transparent items are reduced to the
item that they reveal. This is useful when wanting to know
the effective color. When {trans} is zero, the transparent
item is returned. This is useful when wanting to know which
syntax item is effective (e.g. inside parens).
Warning: This function can be very slow. Best speed is
obtained by going through the file in forward direction.
Example (echoes the name of the syntax item under the cursor):
:echo synIDattr(synID(line("."), col("."), 1), "name")
據我所知,你能做的最好的是:syntax
,這將給你加載的所有語法上的列表當前文件。我不知道任何可以對當前緩衝區進行合理解析的東西。
請注意,:syntax
只是定義了語法項目,它是:highlight
命令的用法,它給出了語法項目的顏色。
一旦你決定要做什麼改變,把它們放在~/.vim/after/syntax/<filetype>.vim
。這些將在加載默認語法文件後應用您的更改。
現貨 - 謝謝! – nelstrom 2009-09-23 21:14:43
我只做了一個改變:爲了一致性,將命令映射到ctrl-shift-p。 'nmap:致電 SynStack()' –
nelstrom
2009-09-23 21:28:36