Home Explore Blog CI



neovim

53th chunk of `runtime/doc/syntax.txt`
6c173d641b0d004b3410dd1e9ce3a00a9ce88976f508ae030000000100000fbc
 highlighted
itself, but will take the highlighting of the item it is contained in.	This
is useful for syntax items that don't need any highlighting but are used
only to skip over a part of the text.

The "contains=" argument is also inherited from the item it is contained in,
unless a "contains" argument is given for the transparent item itself.	To
avoid that unwanted items are contained, use "contains=NONE".  Example, which
highlights words in strings, but makes an exception for "vim": >
	:syn match myString /'[^']*'/ contains=myWord,myVim
	:syn match myWord   /\<[a-z]*\>/ contained
	:syn match myVim    /\<vim\>/ transparent contained contains=NONE
	:hi link myString String
	:hi link myWord   Comment
Since the "myVim" match comes after "myWord" it is the preferred match (last
match in the same position overrules an earlier one).  The "transparent"
argument makes the "myVim" match use the same highlighting as "myString".  But
it does not contain anything.  If the "contains=NONE" argument would be left
out, then "myVim" would use the contains argument from myString and allow
"myWord" to be contained, which will be highlighted as a Comment.  This
happens because a contained match doesn't match inside itself in the same
position, thus the "myVim" match doesn't overrule the "myWord" match here.

When you look at the colored text, it is like looking at layers of contained
items.	The contained item is on top of the item it is contained in, thus you
see the contained item.  When a contained item is transparent, you can look
through, thus you see the item it is contained in.  In a picture:

		look from here

	    |	|   |	|   |	|
	    V	V   V	V   V	V

	       xxxx	  yyy		more contained items
	    ....................	contained item (transparent)
	=============================	first item

The 'x', 'y' and '=' represent a highlighted syntax item.  The '.' represent a
transparent group.

What you see is:

	=======xxxx=======yyy========

Thus you look through the transparent "....".


oneline							*:syn-oneline*

The "oneline" argument indicates that the region does not cross a line
boundary.  It must match completely in the current line.  However, when the
region has a contained item that does cross a line boundary, it continues on
the next line anyway.  A contained item can be used to recognize a line
continuation pattern.  But the "end" pattern must still match in the first
line, otherwise the region doesn't even start.

When the start pattern includes a "\n" to match an end-of-line, the end
pattern must be found in the same line as where the start pattern ends.  The
end pattern may also include an end-of-line.  Thus the "oneline" argument
means that the end of the start pattern and the start of the end pattern must
be within one line.  This can't be changed by a skip pattern that matches a
line break.


fold							*:syn-fold*

The "fold" argument makes the fold level increase by one for this item.
Example: >
   :syn region myFold start="{" end="}" transparent fold
   :syn sync fromstart
   :set foldmethod=syntax
This will make each {} block form one fold.

The fold will start on the line where the item starts, and end where the item
ends.  If the start and end are within the same line, there is no fold.
The 'foldnestmax' option limits the nesting of syntax folds.
See |:syn-foldlevel| to control how the foldlevel of a line is computed
from its syntax items.


			*:syn-contains* *E405* *E406* *E407* *E408* *E409*
contains={group-name},..

The "contains" argument is followed by a list of syntax group names.  These
groups will be allowed to begin inside the item (they may extend past the
containing group's end).  This allows for recursive nesting of matches and
regions.  If there is no "contains" argument, no groups will be contained in
this item.  The group names do not need to be defined before they can be used
here.

contains=ALL
		If the only item in the contains list is "ALL", then all
		groups will be accepted inside the item.

contains=ALLBUT,{group-name},..

Title: Vim Syntax Highlighting: transparent, oneline, fold, and contains arguments
Summary
This section further details arguments to the `:syntax` command. It elaborates on the `transparent` argument, showcasing how it interacts with `contains` and `contains=NONE`. It explains how `oneline` restricts a region to a single line, while allowing contained items to cross line boundaries. The `fold` argument is introduced, demonstrating how to increase the fold level for syntax items. Finally, the `contains` argument and its usage with `ALL` and `ALLBUT` are explained.