Home Explore Blog CI



neovim

43th chunk of `runtime/doc/vimfn.txt`
47eadb76b1af2fc4a2330672dca7a7a8c8493e50b2fb6b220000000100000fb9
	tag		tags
		tag_listfiles	tags, file names
		user		user names
		var		user variables

		If {pat} is an empty string, then all the matches are
		returned.  Otherwise only items matching {pat} are returned.
		See |wildcards| for the use of special characters in {pat}.

		If the optional {filtered} flag is set to 1, then 'wildignore'
		is applied to filter the results.  Otherwise all the matches
		are returned. The 'wildignorecase' option always applies.

		If the 'wildoptions' option contains "fuzzy", then fuzzy
		matching is used to get the completion matches. Otherwise
		regular expression matching is used.  Thus this function
		follows the user preference, what happens on the command line.
		If you do not want this you can make 'wildoptions' empty
		before calling getcompletion() and restore it afterwards.

		If {type} is "cmdline", then the |cmdline-completion| result is
		returned.  For example, to complete the possible values after
		a ":call" command: >vim
			echo getcompletion('call ', 'cmdline')
<
		If there are no matches, an empty list is returned.  An
		invalid value for {type} produces an error.

                Parameters: ~
                  • {pat} (`string`)
                  • {type} (`string`)
                  • {filtered} (`boolean?`)

                Return: ~
                  (`string[]`)

getcurpos([{winid}])                                               *getcurpos()*
		Get the position of the cursor.  This is like getpos('.'), but
		includes an extra "curswant" item in the list:
		    [0, lnum, col, off, curswant] ~
		The "curswant" number is the preferred column when moving the
		cursor vertically.  After |$| command it will be a very large
		number equal to |v:maxcol|.  Also see |getcursorcharpos()| and
		|getpos()|.
		The first "bufnum" item is always zero. The byte position of
		the cursor is returned in "col". To get the character
		position, use |getcursorcharpos()|.

		The optional {winid} argument can specify the window.  It can
		be the window number or the |window-ID|.  The last known
		cursor position is returned, this may be invalid for the
		current value of the buffer if it is not the current window.
		If {winid} is invalid a list with zeroes is returned.

		This can be used to save and restore the cursor position: >vim
			let save_cursor = getcurpos()
			MoveTheCursorAround
			call setpos('.', save_cursor)
<		Note that this only works within the window.  See
		|winrestview()| for restoring more state.

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

                Return: ~
                  (`[integer, integer, integer, integer, integer]`)

getcursorcharpos([{winid}])                                 *getcursorcharpos()*
		Same as |getcurpos()| but the column number in the returned
		List is a character index instead of a byte index.

		Example:
		With the cursor on '보' in line 3 with text "여보세요": >vim
			getcursorcharpos()	" returns [0, 3, 2, 0, 3]
			getcurpos()		" returns [0, 3, 4, 0, 3]
<

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

                Return: ~
                  (`any`)

getcwd([{winnr} [, {tabnr}]])                                         *getcwd()*
		With no arguments, returns the name of the effective
		|current-directory|. With {winnr} or {tabnr} the working
		directory of that scope is returned, and 'autochdir' is
		ignored.
		Tabs and windows are identified by their respective numbers,
		0 means current tab or window. Missing tab number implies 0.
		Thus the following are equivalent: >vim
			getcwd(0)
			getcwd(0, 0)
<		If {winnr} is -1 it is ignored, only the tab is resolved.
		{winnr} can be the window number or the |window-ID|.
		If both {winnr} and {tabnr} are -1 the global working
		directory is returned.
		Throw error if the arguments are invalid. |E5000| |E5001| |E5002|

                Parameters: ~
                  • {winnr} (`integer?`)
                  • {tabnr} (`integer?`)

                Return: ~

Title: Vimscript: getcompletion() continued, getcurpos(), getcursorcharpos(), and getcwd()
Summary
This section describes more Vimscript functions. The getcompletion() function returns a list of command-line completion matches based on a pattern and type. The getcurpos() function returns the cursor's position as a list containing buffer number, line number, column, offset, and preferred column for vertical movement. getcursorcharpos() does the same, but returns the column as a character index instead of a byte index. The getcwd() function returns the current working directory. It can optionally take a window number or tab number to return the working directory of that scope.