Home Explore Blog CI



neovim

60th chunk of `runtime/doc/syntax.txt`
f7512fd83377f13d144f77d455540a136e2090fb61aa73000000000100000fa4
 perlPOD start="^=head" end="^=cut" contains=@Pod
<
	  When {file-name} is an absolute path (starts with "/", "c:", "$VAR"
	  or "<sfile>") that file is sourced.  When it is a relative path
	  (e.g., "syntax/pod.vim") the file is searched for in 'runtimepath'.
	  All matching files are loaded.  Using a relative path is
	  recommended, because it allows a user to replace the included file
	  with their own version, without replacing the file that does the
	  ":syn include".

						*E847*
The maximum number of includes is 999.

==============================================================================
11. Synchronizing				*:syn-sync* *E403* *E404*

Vim wants to be able to start redrawing in any position in the document.  To
make this possible it needs to know the syntax state at the position where
redrawing starts.

:sy[ntax] sync [ccomment [group-name] | minlines={N} | ...]

There are four ways to synchronize:
1. Always parse from the start of the file.
   |:syn-sync-first|
2. Based on C-style comments.  Vim understands how C-comments work and can
   figure out if the current line starts inside or outside a comment.
   |:syn-sync-second|
3. Jumping back a certain number of lines and start parsing there.
   |:syn-sync-third|
4. Searching backwards in the text for a pattern to sync on.
   |:syn-sync-fourth|

				*:syn-sync-maxlines* *:syn-sync-minlines*
For the last three methods, the line range where the parsing can start is
limited by "minlines" and "maxlines".

If the "minlines={N}" argument is given, the parsing always starts at least
that many lines backwards.  This can be used if the parsing may take a few
lines before it's correct, or when it's not possible to use syncing.

If the "maxlines={N}" argument is given, the number of lines that are searched
for a comment or syncing pattern is restricted to N lines backwards (after
adding "minlines").  This is useful if you have few things to sync on and a
slow machine.  Example: >
   :syntax sync maxlines=500 ccomment
<
						*:syn-sync-linebreaks*
When using a pattern that matches multiple lines, a change in one line may
cause a pattern to no longer match in a previous line.	This means has to
start above where the change was made.	How many lines can be specified with
the "linebreaks" argument.  For example, when a pattern may include one line
break use this: >
   :syntax sync linebreaks=1
The result is that redrawing always starts at least one line before where a
change was made.  The default value for "linebreaks" is zero.  Usually the
value for "minlines" is bigger than "linebreaks".


First syncing method:			*:syn-sync-first*
>
   :syntax sync fromstart

The file will be parsed from the start.  This makes syntax highlighting
accurate, but can be slow for long files.  Vim caches previously parsed text,
so that it's only slow when parsing the text for the first time.  However,
when making changes some part of the text needs to be parsed again (worst
case: to the end of the file).

Using "fromstart" is equivalent to using "minlines" with a very large number.


Second syncing method:			*:syn-sync-second* *:syn-sync-ccomment*

For the second method, only the "ccomment" argument needs to be given.
Example: >
   :syntax sync ccomment

When Vim finds that the line where displaying starts is inside a C-style
comment, the last region syntax item with the group-name "Comment" will be
used.  This requires that there is a region with the group-name "Comment"!
An alternate group name can be specified, for example: >
   :syntax sync ccomment javaComment
This means that the last item specified with "syn region javaComment" will be
used for the detected C comment region.  This only works properly if that
region does have a start pattern "\/*" and an end pattern "*\/".

The "maxlines" argument can be used to restrict the search to a number of
lines.	The "minlines" argument can be used to at least start a number of
lines back (e.g., for when there is some construct that only takes a few
lines,

Title: Vim Syntax Synchronization Methods
Summary
This section details syntax synchronization in Vim, explaining how Vim determines the syntax state for redrawing. It covers using absolute vs. relative paths for included files, with a recommendation for relative paths. It then describes four synchronization methods: parsing from the start, using C-style comments, jumping back a number of lines, and searching backwards for a pattern. The use of 'minlines', 'maxlines' and 'linebreaks' to control the line range for parsing. It then explains how to use the "fromstart" and "ccomment" arguments, providing examples for C-style comments and alternative group names.