Home Explore Blog CI



neovim

38th chunk of `runtime/doc/vimfn.txt`
315bbd99b86454d6a6fa5acead831d010105d3766a9f92060000000100000fb3
 is treated as {end} is set to the number of lines in the
		buffer.  When {end} is before {lnum} an empty |List| is
		returned.

		This function works only for loaded buffers.  For unloaded and
		non-existing buffers, an empty |List| is returned.

		Example: >vim
			let lines = getbufline(bufnr("myfile"), 1, "$")
<

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

                Return: ~
                  (`string[]`)

getbufoneline({buf}, {lnum})                                   *getbufoneline()*
		Just like `getbufline()` but only get one line and return it
		as a string.

                Parameters: ~
                  • {buf} (`integer|string`)
                  • {lnum} (`integer`)

                Return: ~
                  (`string`)

getbufvar({buf}, {varname} [, {def}])                              *getbufvar()*
		The result is the value of option or local buffer variable
		{varname} in buffer {buf}.  Note that the name without "b:"
		must be used.
		The {varname} argument is a string.
		When {varname} is empty returns a |Dictionary| with all the
		buffer-local variables.
		When {varname} is equal to "&" returns a |Dictionary| with all
		the buffer-local options.
		Otherwise, when {varname} starts with "&" returns the value of
		a buffer-local option.
		This also works for a global or buffer-local option, but it
		doesn't work for a global variable, window-local variable or
		window-local option.
		For the use of {buf}, see |bufname()| above.
		When the buffer or variable doesn't exist {def} or an empty
		string is returned, there is no error message.
		Examples: >vim
			let bufmodified = getbufvar(1, "&mod")
			echo "todo myvar = " .. getbufvar("todo", "myvar")

                Parameters: ~
                  • {buf} (`integer|string`)
                  • {varname} (`string`)
                  • {def} (`any?`)

                Return: ~
                  (`any`)

getcellwidths()                                                *getcellwidths()*
		Returns a |List| of cell widths of character ranges overridden
		by |setcellwidths()|.  The format is equal to the argument of
		|setcellwidths()|.  If no character ranges have their cell
		widths overridden, an empty List is returned.

                Return: ~
                  (`any`)

getchangelist([{buf}])                                         *getchangelist()*
		Returns the |changelist| for the buffer {buf}. For the use
		of {buf}, see |bufname()| above. If buffer {buf} doesn't
		exist, an empty list is returned.

		The returned list contains two entries: a list with the change
		locations and the current position in the list.  Each
		entry in the change list is a dictionary with the following
		entries:
			col		column number
			coladd		column offset for 'virtualedit'
			lnum		line number
		If buffer {buf} is the current buffer, then the current
		position refers to the position in the list. For other
		buffers, it is set to the length of the list.

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

                Return: ~
                  (`table[]`)

getchar([{expr} [, {opts}]])                                         *getchar()*
		Get a single character from the user or input stream.
		If {expr} is omitted or is -1, wait until a character is
			available.
		If {expr} is 0, only get a character when one is available.
			Return zero otherwise.
		If {expr} is 1, only check if a character is available, it is
			not consumed.  Return zero if no character available.
		If you prefer always getting a string use |getcharstr()|, or
		specify |FALSE| as "number" in {opts}.

		Without {expr} and when {expr} is 0 a whole character or
		special key is returned.  If it is a single character, the
		result is a Number.  Use |nr2char()| to convert it to a String.
		Otherwise a String is returned with the encoded character.
		For a special key it's a

Title: Vimscript Functions for Buffer Manipulation and User Input
Summary
This section describes `getbufoneline()` as a streamlined version of `getbufline()`, returning a single line from a buffer as a string. The function `getbufvar()` retrieves buffer-local variables or options, also allowing retrieval of all buffer-local variables as a Dictionary. It explains how to use `getcellwidths()` to get a List of cell widths overridden by `setcellwidths()`. The function `getchangelist()` fetches the changelist for a given buffer, providing change locations and the current position. Finally, `getchar()` is introduced for getting a single character from the user or input stream with options for blocking or non-blocking behavior.