Tip #99: How to tell what syntax highlighting group *that* is!
tip karma |
Rating 87/36, Viewed by 4744
|
Read and edit this tip on the
Vim tip wiki.
The wiki may have a more recent version of this tip.
created: |
|
August 14, 2001 8:57 |
|
complexity: |
|
intermediate |
author: |
|
Charles E. Campbell, Jr. |
|
as of Vim: |
|
5.7 |
Here's a (what should be a one-line) map to help you tell just what
syntax highlighting groups the item under the cursor actually is:
map <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
Once known you can override the current highlighting with whatever you want.
If you're debugging a syntax highlighting file (a rare occupation), sometimes
you'll wish to know the entire chain of syntax highlighting. For that,
check out
http://www.erols.com/astronaut/vim/vimscript/hilinks.vim
<< Getting vim help from mailing lists and newsgroups. |
Jump to tag (e.g. help topic) with German keyboard (PC) >>
Additional Notes
[email protected],
December 19, 2001 7:33
|
Example: Looking at the syntax/vim.vim file's
syn match vimSpecFile "<c\(word\|WORD\)>" nextgroup=...
Put the cursor on the "\(" in the string, hit <F10>:
hi<vimPatSep> trans<vimPatSep> lo<Special>
will show up on the status line. You may envisage the highlighting
as a push-down stack of highlighting groups. The "highest" one is
the most limited in scope, and is the name of the syntax keyword, match,
or region. Generally such a syntax group is linked to a highlighting
group. The "lowest" one is the basic highlighting specification, and
probably has a broad reach -- in this case, "Special" is a default
highlighting group used in 179 syntax highlighting files (vim 6.0) for
a variety of purposes.
Syntax groups can be specified as being transparent, so that whatever
group they're in is what is used for highlighting. If that's the case,
the group mentioned in "trans<>" will be the name of that group, else
it is a repeat of the "hi<>" group name.
With the highlighting script (hilinks.vim), you'll get (via \hlt):
vimPatSep -> SpecialChar -> Special
which shows the entire highlighting chain. Thus, a "\(" is identified as
being highlighted as a vimPatSep, which is a link to SpecialChar, which
itself is a link to Special. Actually a "\(" is a vimPatSepZone region
which has vimPatSep as its "matchgroup".
|
[email protected] - NOSPAM,
January 25, 2007 7:02
|
My website has moved; its now http://mysite.verizon.net/astronaut/index.html
|
|