Home Explore Blog CI



neovim

47th chunk of `runtime/doc/vimfn.txt`
0d317a4efe723eb00148f77fc730d9c86636458b1dd0dc280000000100000fa7
 prefixed by "'"
		    pos	   a |List| with the position of the mark:
				[bufnum, lnum, col, off]
			   Refer to |getpos()| for more information.
		    file   file name

		Refer to |getpos()| for getting information about a specific
		mark.

                Parameters: ~
                  • {buf} (`integer??`)

                Return: ~
                  (`vim.fn.getmarklist.ret.item[]`)

getmatches([{win}])                                               *getmatches()*
		Returns a |List| with all matches previously defined for the
		current window by |matchadd()| and the |:match| commands.
		|getmatches()| is useful in combination with |setmatches()|,
		as |setmatches()| can restore a list of matches saved by
		|getmatches()|.
		If {win} is specified, use the window with this number or
		window ID instead of the current window.  If {win} is invalid,
		an empty list is returned.
		Example: >vim
			echo getmatches()
<		 >
			[{"group": "MyGroup1", "pattern": "TODO",
			"priority": 10, "id": 1}, {"group": "MyGroup2",
			"pattern": "FIXME", "priority": 10, "id": 2}]
<		 >vim
			let m = getmatches()
			call clearmatches()
			echo getmatches()
<		 >
			[]
<		 >vim
			call setmatches(m)
			echo getmatches()
<		 >
			[{"group": "MyGroup1", "pattern": "TODO",
			"priority": 10, "id": 1}, {"group": "MyGroup2",
			"pattern": "FIXME", "priority": 10, "id": 2}]
<		 >vim
			unlet m
<

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

                Return: ~
                  (`vim.fn.getmatches.ret.item[]`)

getmousepos()                                                    *getmousepos()*
		Returns a |Dictionary| with the last known position of the
		mouse.  This can be used in a mapping for a mouse click.  The
		items are:
			screenrow	screen row
			screencol	screen column
			winid		Window ID of the click
			winrow		row inside "winid"
			wincol		column inside "winid"
			line		text line inside "winid"
			column		text column inside "winid"
			coladd		offset (in screen columns) from the
					start of the clicked char
		All numbers are 1-based.

		If not over a window, e.g. when in the command line, then only
		"screenrow" and "screencol" are valid, the others are zero.

		When on the status line below a window or the vertical
		separator right of a window, the "line" and "column" values
		are zero.

		When the position is after the text then "column" is the
		length of the text in bytes plus one.

		If the mouse is over a focusable floating window then that
		window is used.

		When using |getchar()| the Vim variables |v:mouse_lnum|,
		|v:mouse_col| and |v:mouse_winid| also provide these values.

                Return: ~
                  (`vim.fn.getmousepos.ret`)

getpid()                                                              *getpid()*
		Return a Number which is the process ID of the Vim process.
		This is a unique number, until Vim exits.

                Return: ~
                  (`integer`)

getpos({expr})                                                        *getpos()*
		Get the position for String {expr}.
		The accepted values for {expr} are:
		    .	    The cursor position.
		    $	    The last line in the current buffer.
		    'x	    Position of mark x (if the mark is not set, 0 is
			    returned for all values).
		    w0	    First line visible in current window (one if the
			    display isn't updated, e.g. in silent Ex mode).
		    w$	    Last line visible in current window (this is one
			    less than "w0" if no lines are visible).
		    v	    When not in Visual mode, returns the cursor
			    position.  In Visual mode, returns the other end
			    of the Visual area.  A good way to think about
			    this is that in Visual mode "v" and "." complement
			    each other.  While "." refers to the cursor
			    position, "v" refers to where |v_o| would move the
			    cursor.  As a result, you can use "v" and "."
			    together to work on all of a selection in
			    characterwise Visual mode.  If the

Title: Vimscript: Retrieving Matches, Mouse Position, Process ID, and Position Information
Summary
This section details the Vimscript functions `getmatches()`, `getmousepos()`, `getpid()`, and `getpos()`. `getmatches()` retrieves a list of matches defined for a window and demonstrates how to save and restore matches using `setmatches()`. `getmousepos()` returns a dictionary with the last known mouse position. `getpid()` returns the process ID of the Vim process. `getpos()` gets the position for a string expression, such as the cursor position or a mark.