Home Explore Blog CI



neovim

46th chunk of `runtime/doc/vimfn.txt`
9e9c2663901a234231fc964f534c5aa019c5a977a48539380000000100000fad
                                           *getline()*
		Without {end} the result is a String, which is line {lnum}
		from the current buffer.  Example: >vim
			getline(1)
<		When {lnum} is a String that doesn't start with a
		digit, |line()| is called to translate the String into a Number.
		To get the line under the cursor: >vim
			getline(".")
<		When {lnum} is a number smaller than 1 or bigger than the
		number of lines in the buffer, an empty string is returned.

		When {end} is given the result is a |List| where each item is
		a line from the current buffer in the range {lnum} to {end},
		including line {end}.
		{end} is used in the same way as {lnum}.
		Non-existing lines are silently omitted.
		When {end} is before {lnum} an empty |List| is returned.
		Example: >vim
			let start = line('.')
			let end = search("^$") - 1
			let lines = getline(start, end)

<		To get lines from another buffer see |getbufline()| and
		|getbufoneline()|

                Parameters: ~
                  • {lnum} (`integer|string`)
                  • {end} (`nil|false?`)

                Return: ~
                  (`string`)

getloclist({nr} [, {what}])                                       *getloclist()*
		Returns a |List| with all the entries in the location list for
		window {nr}.  {nr} can be the window number or the |window-ID|.
		When {nr} is zero the current window is used.

		For a location list window, the displayed location list is
		returned.  For an invalid window number {nr}, an empty list is
		returned. Otherwise, same as |getqflist()|.

		If the optional {what} dictionary argument is supplied, then
		returns the items listed in {what} as a dictionary. Refer to
		|getqflist()| for the supported items in {what}.

		In addition to the items supported by |getqflist()| in {what},
		the following item is supported by |getloclist()|:

			filewinid	id of the window used to display files
					from the location list. This field is
					applicable only when called from a
					location list window. See
					|location-list-file-window| for more
					details.

		Returns a |Dictionary| with default values if there is no
		location list for the window {nr}.
		Returns an empty Dictionary if window {nr} does not exist.

		Examples (See also |getqflist-examples|): >vim
			echo getloclist(3, {'all': 0})
			echo getloclist(5, {'filewinid': 0})
<

                Parameters: ~
                  • {nr} (`integer`)
                  • {what} (`table?`)

                Return: ~
                  (`any`)

getmarklist([{buf}])                                             *getmarklist()*
		Without the {buf} argument returns a |List| with information
		about all the global marks. |mark|

		If the optional {buf} argument is specified, returns the
		local marks defined in buffer {buf}.  For the use of {buf},
		see |bufname()|.  If {buf} is invalid, an empty list is
		returned.

		Each item in the returned List is a |Dict| with the following:
		    mark   name of the mark 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},

Title: Vimscript: Retrieving Lines, Location Lists, Marks, and Matches
Summary
This section describes the Vimscript functions `getline()`, `getloclist()`, `getmarklist()`, and `getmatches()`. `getline()` retrieves a line or range of lines from the current buffer. `getloclist()` returns a list of entries in the location list for a window. `getmarklist()` returns information about global or local marks. `getmatches()` returns a list of matches defined for a window using `matchadd()` or `:match`.