Home Explore Blog CI



neovim

36th chunk of `runtime/doc/vimfn.txt`
7fb37f0cbe538a0f2efd8b108d91ca2b586063e9f546c86b0000000100000fb8
 references in a script that runs
		for a long time.

		When the optional {atexit} argument is one, garbage
		collection will also be done when exiting Vim, if it wasn't
		done before.  This is useful when checking for memory leaks.

		The garbage collection is not done immediately but only when
		it's safe to perform.  This is when waiting for the user to
		type a character.

                Parameters: ~
                  • {atexit} (`boolean?`)

                Return: ~
                  (`any`)

get({list}, {idx} [, {default}])                              *get()* *get()-list*
		Get item {idx} from |List| {list}.  When this item is not
		available return {default}.  Return zero when {default} is
		omitted.

                Parameters: ~
                  • {list} (`any[]`)
                  • {idx} (`integer`)
                  • {default} (`any?`)

                Return: ~
                  (`any`)

get({blob}, {idx} [, {default}])                                    *get()-blob*
		Get byte {idx} from |Blob| {blob}.  When this byte is not
		available return {default}.  Return -1 when {default} is
		omitted.

                Parameters: ~
                  • {blob} (`string`)
                  • {idx} (`integer`)
                  • {default} (`any?`)

                Return: ~
                  (`any`)

get({dict}, {key} [, {default}])                                    *get()-dict*
		Get item with key {key} from |Dictionary| {dict}.  When this
		item is not available return {default}.  Return zero when
		{default} is omitted.  Useful example: >vim
			let val = get(g:, 'var_name', 'default')
<		This gets the value of g:var_name if it exists, and uses
		"default" when it does not exist.

                Parameters: ~
                  • {dict} (`table<string,any>`)
                  • {key} (`string`)
                  • {default} (`any?`)

                Return: ~
                  (`any`)

get({func}, {what})                                                 *get()-func*
		Get item {what} from |Funcref| {func}.  Possible values for
		{what} are:
		  "name"    The function name
		  "func"    The function
		  "dict"    The dictionary
		  "args"    The list with arguments
		  "arity"   A dictionary with information about the number of
			    arguments accepted by the function (minus the
			    {arglist}) with the following fields:
				required    the number of positional arguments
				optional    the number of optional arguments,
					    in addition to the required ones
				varargs     |TRUE| if the function accepts a
					    variable number of arguments |...|

				Note: There is no error, if the {arglist} of
				the Funcref contains more arguments than the
				Funcref expects, it's not validated.

		Returns zero on error.

                Parameters: ~
                  • {func} (`function`)
                  • {what} (`string`)

                Return: ~
                  (`any`)

getbufinfo([{buf}])                                               *getbufinfo()*
getbufinfo([{dict}])
		Get information about buffers as a List of Dictionaries.

		Without an argument information about all the buffers is
		returned.

		When the argument is a |Dictionary| only the buffers matching
		the specified criteria are returned.  The following keys can
		be specified in {dict}:
			buflisted	include only listed buffers.
			bufloaded	include only loaded buffers.
			bufmodified	include only modified buffers.

		Otherwise, {buf} specifies a particular buffer to return
		information for.  For the use of {buf}, see |bufname()|
		above.  If the buffer is found the returned List has one item.
		Otherwise the result is an empty list.

		Each returned List item is a dictionary with the following
		entries:
			bufnr		Buffer number.
			changed		TRUE if the buffer is modified.
			changedtick	Number of changes made to the buffer.
			command		TRUE if the buffer belongs to the
					command-line window |cmdwin|.
			hidden		TRUE if the buffer is hidden.
	

Title: Garbage Collection, List/Blob/Dictionary Access, and Buffer Information in Vimscript
Summary
This section covers the `garbagecollect()` function, including optional arguments for memory leak checks, and how it handles garbage collection timing. It details the `get()` function for accessing items from Lists, Blobs, and Dictionaries, providing examples for default values. It describes `get()-func` for retrieving information from a Funcref. The section concludes with `getbufinfo()`, explaining how to retrieve information about buffers using different arguments and specifying the dictionary keys available for more advanced search criteria.