Home Explore Blog CI



neovim

27th chunk of `runtime/doc/vimfn.txt`
289149f2a96e8e6ab3e0783e9c51233bd58f08780896ecc70000000100000fb0
 file name is expanded on the command line.
		'suffixes' and 'wildignore' are used, unless the optional
		{nosuf} argument is given and it is |TRUE|.
		Names for non-existing files are included.  The "**" item can
		be used to search in a directory tree.  For example, to find
		all "README" files in the current directory and below: >vim
			echo expand("**/README")
<
		expand() can also be used to expand variables and environment
		variables that are only known in a shell.  But this can be
		slow, because a shell may be used to do the expansion.  See
		|expr-env-expand|.
		The expanded variable is still handled like a list of file
		names.  When an environment variable cannot be expanded, it is
		left unchanged.  Thus ":echo expand('$FOOBAR')" results in
		"$FOOBAR".

		See |glob()| for finding existing files.  See |system()| for
		getting the raw output of an external command.

                Parameters: ~
                  • {string} (`string`)
                  • {nosuf} (`boolean?`)
                  • {list} (`nil|false?`)

                Return: ~
                  (`string`)

expandcmd({string} [, {options}])                                  *expandcmd()*
		Expand special items in String {string} like what is done for
		an Ex command such as `:edit`.  This expands special keywords,
		like with |expand()|, and environment variables, anywhere in
		{string}.  "~user" and "~/path" are only expanded at the
		start.

		The following items are supported in the {options} Dict
		argument:
		    errmsg	If set to TRUE, error messages are displayed
				if an error is encountered during expansion.
				By default, error messages are not displayed.

		Returns the expanded string.  If an error is encountered
		during expansion, the unmodified {string} is returned.

		Example: >vim
			echo expandcmd('make %<.o')
<		 >
			make /path/runtime/doc/builtin.o
<		 >vim
			echo expandcmd('make %<.o', {'errmsg': v:true})
<

                Parameters: ~
                  • {string} (`string`)
                  • {options} (`table?`)

                Return: ~
                  (`any`)

extend({expr1}, {expr2} [, {expr3}])                                  *extend()*
		{expr1} and {expr2} must be both |Lists| or both
		|Dictionaries|.

		If they are |Lists|: Append {expr2} to {expr1}.
		If {expr3} is given insert the items of {expr2} before the
		item with index {expr3} in {expr1}.  When {expr3} is zero
		insert before the first item.  When {expr3} is equal to
		len({expr1}) then {expr2} is appended.
		Examples: >vim
			echo sort(extend(mylist, [7, 5]))
			call extend(mylist, [2, 3], 1)
<		When {expr1} is the same List as {expr2} then the number of
		items copied is equal to the original length of the List.
		E.g., when {expr3} is 1 you get N new copies of the first item
		(where N is the original length of the List).
		Use |add()| to concatenate one item to a list.  To concatenate
		two lists into a new list use the + operator: >vim
			let newlist = [1, 2, 3] + [4, 5]
<
		If they are |Dictionaries|:
		Add all entries from {expr2} to {expr1}.
		If a key exists in both {expr1} and {expr2} then {expr3} is
		used to decide what to do:
		{expr3} = "keep": keep the value of {expr1}
		{expr3} = "force": use the value of {expr2}
		{expr3} = "error": give an error message		*E737*
		When {expr3} is omitted then "force" is assumed.

		{expr1} is changed when {expr2} is not empty.  If necessary
		make a copy of {expr1} first or use |extendnew()| to return a
		new List/Dictionary.
		{expr2} remains unchanged.
		When {expr1} is locked and {expr2} is not empty the operation
		fails.
		Returns {expr1}.  Returns 0 on error.

                Parameters: ~
                  • {expr1} (`table`)
                  • {expr2} (`table`)
                  • {expr3} (`table?`)

                Return: ~
                  (`any`)

extendnew({expr1}, {expr2} [, {expr3}])                            *extendnew()*
		Like |extend()| but instead of adding items to {expr1} a new

Title: Vimscript Functions: `expand()` (continued), `expandcmd()`, and `extend()`
Summary
This section describes the `expand()`, `expandcmd()`, and `extend()` functions in Vimscript. It details how `expand()` handles file names, variables, and environment variables, including the use of 'suffixes' and 'wildignore'. `expandcmd()` expands special items similar to Ex commands, while `extend()` appends or inserts elements of one list or dictionary into another, with options for conflict resolution in dictionaries. A short description of `extendnew()` is also included, stating it functions similarly to `extend()` but creates a new list/dictionary.