Home Explore Blog CI



neovim

54th chunk of `runtime/doc/syntax.txt`
6a4dc15baee5b38ad92d55b4a32358e10e3b26a86fa9ddb60000000100000faa
 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},..
		If the first item in the contains list is "ALLBUT", then all
		groups will be accepted inside the item, except the ones that
		are listed.  Example: >
  :syntax region Block start="{" end="}" ... contains=ALLBUT,Function

contains=TOP
		If the first item in the contains list is "TOP", then all
		groups will be accepted that don't have the "contained"
		argument.
contains=TOP,{group-name},..
		Like "TOP", but excluding the groups that are listed.

contains=CONTAINED
		If the first item in the contains list is "CONTAINED", then
		all groups will be accepted that have the "contained"
		argument.
contains=CONTAINED,{group-name},..
		Like "CONTAINED", but excluding the groups that are
		listed.


The {group-name} in the "contains" list can be a pattern.  All group names
that match the pattern will be included (or excluded, if "ALLBUT" is used).
The pattern cannot contain white space or a ','.  Example: >
   ... contains=Comment.*,Keyw[0-3]
The matching will be done at moment the syntax command is executed.  Groups
that are defined later will not be matched.  Also, if the current syntax
command defines a new group, it is not matched.  Be careful: When putting
syntax commands in a file you can't rely on groups NOT being defined, because
the file may have been sourced before, and ":syn clear" doesn't remove the
group names.

The contained groups will also match in the start and end patterns of a
region.  If this is not wanted, the "matchgroup" argument can be used
|:syn-matchgroup|.  The "ms=" and "me=" offsets can be used to change the
region where contained items do match.	Note that this may also limit the
area that is highlighted


containedin={group-name}...				*:syn-containedin*

The "containedin" argument is followed by a list of syntax group names.  The
item will be allowed to begin inside these groups.  This works as if the
containing item has a "contains=" argument that includes this item.

The {group-name}... can be used just like for "contains", as explained above.

This is useful when adding a syntax item afterwards.  An item can be told to
be included inside an already existing item, without changing the definition
of that item.  For example, to highlight a word in a C comment after loading
the C syntax: >
	:syn keyword myword HELP containedin=cComment contained
Note that "contained" is also used, to avoid that the item matches at the top
level.

Matches for "containedin" are added to the other places where the item can
appear.  A "contains" argument may also be added as usual.  Don't forget that
keywords never contain another item, thus adding them to "containedin" won't
work.


nextgroup={group-name},..				*:syn-nextgroup*

The "nextgroup" argument is followed by a list of syntax group names,
separated by commas (just like with "contains", so you can also use patterns).

If the "nextgroup" argument is given, the mentioned syntax groups will be
tried for a match, after the match or region ends.  If none of the groups have
a match, highlighting

Title: Vim Syntax Highlighting: contains=TOP/CONTAINED/patterns, containedin, and nextgroup arguments
Summary
This section details additional arguments for the `:syntax` command in Vim. It explains `contains=TOP`, `contains=CONTAINED`, and the use of patterns in the `contains` list. It describes `containedin`, which allows specifying groups where an item can be contained, and `nextgroup`, which specifies which syntax groups to try for a match after the current one ends. It provides examples for each argument.