Home Explore Blog CI



neovim

79th chunk of `runtime/doc/vimfn.txt`
9139fc447f56a88bf00bc8b614f827e54df5e829811569db0000000100000fc1
	lengths.

		Returns -1 on error.

		Example: >vim
			highlight MyGroup ctermbg=green guibg=green
			let m = matchaddpos("MyGroup", [[23, 24], 34])
<		Deletion of the pattern: >vim
			call matchdelete(m)

<		Matches added by |matchaddpos()| are returned by
		|getmatches()|.

                Parameters: ~
                  • {group} (`integer|string`)
                  • {pos} (`any[]`)
                  • {priority} (`integer?`)
                  • {id} (`integer?`)
                  • {dict} (`string?`)

                Return: ~
                  (`any`)

matcharg({nr})                                                      *matcharg()*
		Selects the {nr} match item, as set with a |:match|,
		|:2match| or |:3match| command.
		Return a |List| with two elements:
			The name of the highlight group used
			The pattern used.
		When {nr} is not 1, 2 or 3 returns an empty |List|.
		When there is no match item set returns ['', ''].
		This is useful to save and restore a |:match|.
		Highlighting matches using the |:match| commands are limited
		to three matches. |matchadd()| does not have this limitation.

                Parameters: ~
                  • {nr} (`integer`)

                Return: ~
                  (`any`)

matchbufline({buf}, {pat}, {lnum}, {end}, [, {dict}])           *matchbufline()*
		Returns the |List| of matches in lines from {lnum} to {end} in
		buffer {buf} where {pat} matches.

		{lnum} and {end} can either be a line number or the string "$"
		to refer to the last line in {buf}.

		The {dict} argument supports following items:
		    submatches	include submatch information (|/\(|)

		For each match, a |Dict| with the following items is returned:
		    byteidx	starting byte index of the match
		    lnum	line number where there is a match
		    text	matched string
		Note that there can be multiple matches in a single line.

		This function works only for loaded buffers. First call
		|bufload()| if needed.

		See |match-pattern| for information about the effect of some
		option settings on the pattern.

		When {buf} is not a valid buffer, the buffer is not loaded or
		{lnum} or {end} is not valid then an error is given and an
		empty |List| is returned.

		Examples: >vim
		    " Assuming line 3 in buffer 5 contains "a"
		    echo matchbufline(5, '\<\k\+\>', 3, 3)
<		    `[{'lnum': 3, 'byteidx': 0, 'text': 'a'}]` >vim
		    " Assuming line 4 in buffer 10 contains "tik tok"
		    echo matchbufline(10, '\<\k\+\>', 1, 4)
<		    `[{'lnum': 4, 'byteidx': 0, 'text': 'tik'}, {'lnum': 4, 'byteidx': 4, 'text': 'tok'}]`

		If {submatch} is present and is v:true, then submatches like
		"\1", "\2", etc. are also returned.  Example: >vim
		    " Assuming line 2 in buffer 2 contains "acd"
		    echo matchbufline(2, '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2, 2
						\ {'submatches': v:true})
<		    `[{'lnum': 2, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]`
		The "submatches" List always contains 9 items.  If a submatch
		is not found, then an empty string is returned for that
		submatch.

                Parameters: ~
                  • {buf} (`string|integer`)
                  • {pat} (`string`)
                  • {lnum} (`string|integer`)
                  • {end} (`string|integer`)
                  • {dict} (`table?`)

                Return: ~
                  (`any`)

matchdelete({id} [, {win}])                            *matchdelete()* *E802* *E803*
		Deletes a match with ID {id} previously defined by |matchadd()|
		or one of the |:match| commands.  Returns 0 if successful,
		otherwise -1.  See example for |matchadd()|.  All matches can
		be deleted in one operation by |clearmatches()|.
		If {win} is specified, use the window with this number or
		window ID instead of the current window.

                Parameters: ~
                  • {id} (`integer`)
                  • {win} (`integer?`)

                Return: ~
                  (`any`)

matchend({expr}, {pat} [, {start} [, {count}]])

Title: Vim Function Documentation: matcharg(), matchbufline(), and matchdelete()
Summary
This section documents the `matcharg()`, `matchbufline()`, and `matchdelete()` Vim functions. `matcharg()` selects a match item set with `:match`, `:2match`, or `:3match` and returns a list containing the highlight group name and pattern used. `matchbufline()` returns a list of matches found in specified lines of a buffer, including optional submatch information. `matchdelete()` removes a match defined by `matchadd()` or the `:match` commands, and returns 0 on success or -1 on failure. `clearmatches()` removes all matches at once.