Home Explore Blog CI



neovim

77th chunk of `runtime/doc/vimfn.txt`
a569f0fa89f8aa240f23f3c7f9804c447bb4694d72a83c190000000100000fac
 the
		first character/item.  Example: >vim
			echo match("testing", "ing", 2)
<		result is again "4". >vim
			echo match("testing", "ing", 4)
<		result is again "4". >vim
			echo match("testing", "t", 2)
<		result is "3".
		For a String, if {start} > 0 then it is like the string starts
		{start} bytes later, thus "^" will match at {start}.  Except
		when {count} is given, then it's like matches before the
		{start} byte are ignored (this is a bit complicated to keep it
		backwards compatible).
		For a String, if {start} < 0, it will be set to 0.  For a list
		the index is counted from the end.
		If {start} is out of range ({start} > strlen({expr}) for a
		String or {start} > len({expr}) for a |List|) -1 is returned.

		When {count} is given use the {count}th match.  When a match
		is found in a String the search for the next one starts one
		character further.  Thus this example results in 1: >vim
			echo match("testing", "..", 0, 2)
<		In a |List| the search continues in the next item.
		Note that when {count} is added the way {start} works changes,
		see above.

						*match-pattern*
		See |pattern| for the patterns that are accepted.
		The 'ignorecase' option is used to set the ignore-caseness of
		the pattern.  'smartcase' is NOT used.  The matching is always
		done like 'magic' is set and 'cpoptions' is empty.
		Note that a match at the start is preferred, thus when the
		pattern is using "*" (any number of matches) it tends to find
		zero matches at the start instead of a number of matches
		further down in the text.

                Parameters: ~
                  • {expr} (`string|any[]`)
                  • {pat} (`string`)
                  • {start} (`integer?`)
                  • {count} (`integer?`)

                Return: ~
                  (`any`)

                                                *matchadd()* *E798* *E799* *E801* *E957*
matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]])
		Defines a pattern to be highlighted in the current window (a
		"match").  It will be highlighted with {group}.  Returns an
		identification number (ID), which can be used to delete the
		match using |matchdelete()|.  The ID is bound to the window.
		Matching is case sensitive and magic, unless case sensitivity
		or magicness are explicitly overridden in {pattern}.  The
		'magic', 'smartcase' and 'ignorecase' options are not used.
		The "Conceal" value is special, it causes the match to be
		concealed.

		The optional {priority} argument assigns a priority to the
		match.  A match with a high priority will have its
		highlighting overrule that of a match with a lower priority.
		A priority is specified as an integer (negative numbers are no
		exception).  If the {priority} argument is not specified, the
		default priority is 10.  The priority of 'hlsearch' is zero,
		hence all matches with a priority greater than zero will
		overrule it.  Syntax highlighting (see 'syntax') is a separate
		mechanism, and regardless of the chosen priority a match will
		always overrule syntax highlighting.

		The optional {id} argument allows the request for a specific
		match ID.  If a specified ID is already taken, an error
		message will appear and the match will not be added.  An ID
		is specified as a positive integer (zero excluded).  IDs 1, 2
		and 3 are reserved for |:match|, |:2match| and |:3match|,
		respectively.  3 is reserved for use by the |matchparen|
		plugin.
		If the {id} argument is not specified or -1, |matchadd()|
		automatically chooses a free ID, which is at least 1000.

		The optional {dict} argument allows for further custom
		values. Currently this is used to specify a match specific
		conceal character that will be shown for |hl-Conceal|
		highlighted matches. The dict can have the following members:

			conceal	    Special character to show instead of the
				    match (only for |hl-Conceal| highlighted
				    matches, see |:syn-cchar|)
			window	    Instead of the current window use the
				    window with

Title: Vim Function Documentation: match() and matchadd()
Summary
This section continues the documentation for the `match()` function, explaining how the `{start}` and `{count}` parameters affect the search, including considerations for strings and lists. It specifies the accepted patterns and how 'ignorecase', 'smartcase' and 'cpoptions' options are handled. Additionally, this section begins explaining the `matchadd()` function, which defines a pattern to be highlighted in the current window with a specified highlight group and returns an ID. It covers optional arguments such as priority, a specific ID, and a dictionary for custom values like conceal character.