-- File containing table with all functions. -- -- Keys: -- --- @class vim.EvalFn --- @field name? string --- @field args? integer|integer[] Number of arguments, list with maximum and minimum number of arguments --- or list with a minimum number of arguments only. Defaults to zero --- arguments. --- @field base? integer For methods: the argument to use as the base argument (1-indexed): --- base->method() --- Defaults to BASE_NONE (function cannot be used as a method). --- @field func? string Name of the C function which implements the Vimscript function. Defaults to --- `f_{funcname}`. --- @field float_func? string --- @field fast? boolean Function can run in |api-fast| events. Defaults to false. --- @field deprecated? true --- @field returns? string|false --- @field returns_desc? string --- @field signature string --- @field desc? string --- @field params {[1]:string, [2]:string, [3]:string}[] --- @field lua? false Do not render type information --- @field tags? string[] Extra tags --- @field data? string Used by gen_eval.lua -- Usable with the base key: use the last function argument as the method base. -- Value is from funcs.h file. "BASE_" prefix is omitted. -- local LAST = "BASE_LAST" (currently unused after port of v8.2.1168) local M = {} local VARARGS = { { '...', 'any' } } --- @type table M.funcs = { abs = { args = 1, base = 1, desc = [=[ Return the absolute value of {expr}. When {expr} evaluates to a |Float| abs() returns a |Float|. When {expr} can be converted to a |Number| abs() returns a |Number|. Otherwise abs() gives an error message and returns -1. Examples: >vim echo abs(1.456) < 1.456 >vim echo abs(-5.456) < 5.456 >vim echo abs(-4) < 4 ]=], name = 'abs', params = { { 'expr', 'any' } }, signature = 'abs({expr})', returns = 'number', }, acos = { args = 1, base = 1, desc = [=[ Return the arc cosine of {expr} measured in radians, as a |Float| in the range of [0, pi]. {expr} must evaluate to a |Float| or a |Number| in the range [-1, 1]. Returns NaN if {expr} is outside the range [-1, 1]. Returns 0.0 if {expr} is not a |Float| or a |Number|. Examples: >vim echo acos(0) < 1.570796 >vim echo acos(-0.5) < 2.094395 ]=], float_func = 'acos', name = 'acos', params = { { 'expr', 'any' } }, returns = 'number', signature = 'acos({expr})', }, add = { args = 2, base = 1, desc = [=[ Append the item {expr} to |List| or |Blob| {object}. Returns the resulting |List| or |Blob|. Examples: >vim let alist = add([1, 2, 3], item) call add(mylist, "woodstock") vim let flag = and(bits, 0x80) < ]=], name = 'and', params = { { 'expr', 'any' }, { 'expr', 'any' } }, returns = 'integer', signature = 'and({expr}, {expr})', }, api_info = { desc = [=[ Returns Dictionary of |api-metadata|. View it in a nice human-readable format: >vim lua vim.print(vim.fn.api_info()) < ]=], fast = true, name = 'api_info', params = {}, returns = 'table', signature = 'api_info()', }, append = { args = 2, base = 2, desc = [=[ When {text} is a |List|: Append each item of the |List| as a text line below line {lnum} in the current buffer. Otherwise append {text} as one text line below line {lnum} in the current buffer. Any type of item is accepted and converted to a String. {lnum} can be zero to insert a line before the first one. {lnum} is used like with |getline()|. Returns 1 for failure ({lnum} out of range or out of memory), 0 for success. When {text} is an empty list zero is returned, no matter the value of {lnum}. Example: >vim let failed = append(line('$'), "# THE END") let failed = append(0, ["Chapter 1", "the beginning"]) < ]=], name = 'append', params = { { 'lnum', 'integer' }, { 'text', 'any' } }, returns = '0|1', signature = 'append({lnum}, {text})', }, appendbufline = { args = 3, base = 3, desc = [=[ Like |append()| but append the text in buffer {expr}. This function works only for loaded buffers. First call |bufload()| if needed. For the use of {buf}, see |bufname()|. {lnum} is the line number to append below. Note that using |line()| would use the current buffer, not the one appending to. Use "$" to append at the end of the buffer. Other string values are not supported. On success 0 is returned, on failure 1 is returned. If {buf} is not a valid buffer or {lnum} is not valid, an error message is given. Example: >vim let failed = appendbufline(13, 0, "# THE START") vim let i = 0 while i < argc() let f = escape(fnameescape(argv(i)), '.') exe 'amenu Arg.' .. f .. ' :e ' .. f .. '' let i = i + 1 endwhile vim echo asin(0.8) < 0.927295 >vim echo asin(-0.5) < -0.523599 ]=], float_func = 'asin', name = 'asin', params = { { 'expr', 'any' } }, returns = 'number', signature = 'asin({expr})', }, assert_beeps = { args = 1, base = 1, desc = [=[ Run {cmd} and add an error message to |v:errors| if it does NOT produce a beep or visual bell. Also see |assert_fails()|, |assert_nobeep()| and |assert-return|. ]=], name = 'assert_beeps', params = { { 'cmd', 'any' } }, returns = '0|1', signature = 'assert_beeps({cmd})', }, assert_equal = { args = { 2, 3 }, base = 2, desc = [=[ When {expected} and {actual} are not equal an error message is added to |v:errors| and 1 is returned. Otherwise zero is returned. |assert-return| The error is in the form "Expected {expected} but got {actual}". When {msg} is present it is prefixed to that. There is no automatic conversion, the String "4" is different from the Number 4. And the number 4 is different from the Float 4.0. The value of 'ignorecase' is not used here, case always matters. Example: >vim assert_equal('foo', 'bar') vim try commandthatfails call assert_false(1, 'command should have failed') catch call assert_exception('E492:') endtry < ]=], name = 'assert_exception', params = { { 'error', 'any' }, { 'msg', 'any' } }, returns = '0|1', signature = 'assert_exception({error} [, {msg}])', }, assert_fails = { args = { 1, 5 }, base = 1, desc = [=[ Run {cmd} and add an error message to |v:errors| if it does NOT produce an error or when {error} is not found in the error message. Also see |assert-return|. When {error} is a string it must be found literally in the first reported error. Most often this will be the error code, including the colon, e.g. "E123:". >vim assert_fails('bad cmd', 'E987:') < When {error} is a |List| with one or two strings, these are used as patterns. The first pattern is matched against the first reported error: >vim assert_fails('cmd', ['E987:.*expected bool']) vim assert_fails('cmd', ['', 'E987:']) < If {msg} is empty then it is not used. Do this to get the default message when passing the {lnum} argument. When {lnum} is present and not negative, and the {error} argument is present and matches, then this is compared with the line number at which the error was reported. That can be the line number in a function or in a script. When {context} is present it is used as a pattern and matched against the context (script name or function name) where {lnum} is located in. Note that beeping is not considered an error, and some failing commands only beep. Use |assert_beeps()| for those. ]=], name = 'assert_fails', params = { { 'cmd', 'any' }, { 'error', 'any' }, { 'msg', 'any' }, { 'lnum', 'integer' }, { 'context', 'any' }, }, returns = '0|1', signature = 'assert_fails({cmd} [, {error} [, {msg} [, {lnum} [, {context}]]]])', }, assert_false = { args = { 1, 2 }, base = 1, desc = [=[ When {actual} is not false an error message is added to |v:errors|, like with |assert_equal()|. The error is in the form "Expected False but got {actual}". When {msg} is present it is prepended to that. Also see |assert-return|. A value is false when it is zero. When {actual} is not a number the assert fails. ]=], name = 'assert_false', params = { { 'actual', 'any' }, { 'msg', 'any' } }, returns = '0|1', signature = 'assert_false({actual} [, {msg}])', }, assert_inrange = { args = { 3, 4 }, base = 3, desc = [=[ This asserts number and |Float| values. When {actual} is lower than {lower} or higher than {upper} an error message is added to |v:errors|. Also see |assert-return|. The error is in the form "Expected range {lower} - {upper}, but got {actual}". When {msg} is present it is prefixed to that. ]=], name = 'assert_inrange', params = { { 'lower', 'any' }, { 'upper', 'any' }, { 'actual', 'any' }, { 'msg', 'any' } }, returns = '0|1', signature = 'assert_inrange({lower}, {upper}, {actual} [, {msg}])', }, assert_match = { args = { 2, 3 }, base = 2, desc = [=[ When {pattern} does not match {actual} an error message is added to |v:errors|. Also see |assert-return|. The error is in the form "Pattern {pattern} does not match {actual}". When {msg} is present it is prefixed to that. {pattern} is used as with |expr-=~|: The matching is always done like 'magic' was set and 'cpoptions' is empty, no matter what the actual value of 'magic' or 'cpoptions' is. {actual} is used as a string, automatic conversion applies. Use "^" and "$" to match with the start and end of the text. Use both to match the whole text. Example: >vim assert_match('^f.*o$', 'foobar') vim echo atan(100) < 1.560797 >vim echo atan(-4.01) < -1.326405 ]=], float_func = 'atan', name = 'atan', params = { { 'expr', 'any' } }, returns = 'number', signature = 'atan({expr})', }, atan2 = { args = 2, base = 1, desc = [=[ Return the arc tangent of {expr1} / {expr2}, measured in radians, as a |Float| in the range [-pi, pi]. {expr1} and {expr2} must evaluate to a |Float| or a |Number|. Returns 0.0 if {expr1} or {expr2} is not a |Float| or a |Number|. Examples: >vim echo atan2(-1, 1) < -0.785398 >vim echo atan2(1, -1) < 2.356194 ]=], name = 'atan2', params = { { 'expr1', 'any' }, { 'expr2', 'any' } }, returns = 'number', signature = 'atan2({expr1}, {expr2})', }, blob2list = { args = 1, base = 1, desc = [=[ Return a List containing the number value of each byte in Blob {blob}. Examples: >vim blob2list(0z0102.0304) " returns [1, 2, 3, 4] blob2list(0z) " returns [] vim let bufnr = bufadd('someName') call bufload(bufnr) call setbufline(bufnr, 1, ['some', 'text']) vim echo bufname("3" + 0) vim echo bufname("#") " alternate buffer name echo bufname(3) " name of buffer 3 echo bufname("%") " name of current buffer echo bufname("file2") " name of buffer where "file2" matches. < ]=], name = 'bufname', params = { { 'buf', 'any' } }, returns = 'string', signature = 'bufname([{buf}])', }, bufnr = { args = { 0, 2 }, base = 1, desc = [=[ The result is the number of a buffer, as it is displayed by the `:ls` command. For the use of {buf}, see |bufname()| above. If the buffer doesn't exist, -1 is returned. Or, if the {create} argument is present and TRUE, a new, unlisted, buffer is created and its number is returned. bufnr("$") is the last buffer: >vim let last_buffer = bufnr("$") vim echo "A window containing buffer 1 is " .. (bufwinid(1)) < Only deals with the current tab page. See |win_findbuf()| for finding more. ]=], name = 'bufwinid', params = { { 'buf', 'any' } }, returns = 'integer', signature = 'bufwinid({buf})', }, bufwinnr = { args = 1, base = 1, desc = [=[ Like |bufwinid()| but return the window number instead of the |window-ID|. If buffer {buf} doesn't exist or there is no such window, -1 is returned. Example: >vim echo "A window containing buffer 1 is " .. (bufwinnr(1)) vim echo matchstr(str, ".", byteidx(str, 3)) vim let s = strpart(str, byteidx(str, 3)) echo strpart(s, 0, byteidx(s, 1)) vim echo byteidx('a😊😊', 2) " returns 5 echo byteidx('a😊😊', 2, 1) " returns 1 echo byteidx('a😊😊', 3, 1) " returns 5 < ]=], fast = true, name = 'byteidx', params = { { 'expr', 'any' }, { 'nr', 'integer' }, { 'utf16', 'any' } }, returns = 'integer', signature = 'byteidx({expr}, {nr} [, {utf16}])', }, byteidxcomp = { args = { 2, 3 }, base = 1, desc = [=[ Like byteidx(), except that a composing character is counted as a separate character. Example: >vim let s = 'e' .. nr2char(0x301) echo byteidx(s, 1) echo byteidxcomp(s, 1) echo byteidxcomp(s, 2) vim echo ceil(1.456) < 2.0 >vim echo ceil(-5.456) < -5.0 >vim echo ceil(4.0) < 4.0 Returns 0.0 if {expr} is not a |Float| or a |Number|. ]=], float_func = 'ceil', name = 'ceil', params = { { 'expr', 'any' } }, returns = 'number', signature = 'ceil({expr})', }, chanclose = { args = { 1, 2 }, desc = [=[ Close a channel or a specific stream associated with it. For a job, {stream} can be one of "stdin", "stdout", "stderr" or "rpc" (closes stdin/stdout for a job started with `"rpc":v:true`) If {stream} is omitted, all streams are closed. If the channel is a pty, this will then close the pty master, sending SIGHUP to the job process. For a socket, there is only one stream, and {stream} should be omitted. ]=], name = 'chanclose', params = { { 'id', 'any' }, { 'stream', 'any' } }, returns = '0|1', signature = 'chanclose({id} [, {stream}])', }, changenr = { desc = [=[ Return the number of the most recent change. This is the same number as what is displayed with |:undolist| and can be used with the |:undo| command. When a change was made it is the number of that change. After redo it is the number of the redone change. After undo it is one less than the number of the undone change. Returns 0 if the undo list is empty. ]=], name = 'changenr', params = {}, returns = 'integer', signature = 'changenr()', }, chansend = { args = 2, desc = [=[ Send data to channel {id}. For a job, it writes it to the stdin of the process. For the stdio channel |channel-stdio|, it writes to Nvim's stdout. Returns the number of bytes written if the write succeeded, 0 otherwise. See |channel-bytes| for more information. {data} may be a string, string convertible, |Blob|, or a list. If {data} is a list, the items will be joined by newlines; any newlines in an item will be sent as NUL. To send a final newline, include a final empty string. Example: >vim call chansend(id, ["abc", "123\n456", ""]) 123456". chansend() writes raw data, not RPC messages. If the channel was created with `"rpc":v:true` then the channel expects RPC messages, use |rpcnotify()| and |rpcrequest()| instead. ]=], name = 'chansend', params = { { 'id', 'any' }, { 'data', 'any' } }, returns = '0|1', signature = 'chansend({id}, {data})', }, char2nr = { args = { 1, 2 }, base = 1, desc = [=[ Return Number value of the first char in {string}. Examples: >vim echo char2nr(" ") " returns 32 echo char2nr("ABC") " returns 65 echo char2nr("Γ‘") " returns 225 echo char2nr("Γ‘"[0]) " returns 195 echo char2nr("\") " returns 128 vim echo charcol('.') " returns 3 echo col('.') " returns 7 ]=], name = 'charcol', params = { { 'expr', 'any' }, { 'winid', 'integer' } }, returns = 'integer', signature = 'charcol({expr} [, {winid}])', }, charidx = { args = { 2, 4 }, base = 1, desc = [=[ Return the character index of the byte at {idx} in {string}. The index of the first character is zero. If there are no multibyte characters the returned value is equal to {idx}. When {countcc} is omitted or |FALSE|, then composing characters are not counted separately, their byte length is added to the preceding base character. When {countcc} is |TRUE|, then composing characters are counted as separate characters. When {utf16} is present and TRUE, {idx} is used as the UTF-16 index in the String {expr} instead of as the byte index. Returns -1 if the arguments are invalid or if there are less than {idx} bytes. If there are exactly {idx} bytes the length of the string in characters is returned. An error is given and -1 is returned if the first argument is not a string, the second argument is not a number or when the third argument is present and is not zero or one. See |byteidx()| and |byteidxcomp()| for getting the byte index from the character index and |utf16idx()| for getting the UTF-16 index from the character index. Refer to |string-offset-encoding| for more information. Examples: >vim echo charidx('áb́ć', 3) " returns 1 echo charidx('áb́ć', 6, 1) " returns 4 echo charidx('áb́ć', 16) " returns -1 echo charidx('a😊😊', 4, 0, 1) " returns 2 < ]=], name = 'charidx', params = { { 'string', 'string' }, { 'idx', 'integer' }, { 'countcc', 'any' }, { 'utf16', 'any' }, }, returns = 'integer', signature = 'charidx({string}, {idx} [, {countcc} [, {utf16}]])', }, chdir = { args = 1, base = 1, desc = [=[ Change the current working directory to {dir}. The scope of the directory change depends on the directory of the current window: - If the current window has a window-local directory (|:lcd|), then changes the window local directory. - Otherwise, if the current tabpage has a local directory (|:tcd|) then changes the tabpage local directory. - Otherwise, changes the global directory. {dir} must be a String. If successful, returns the previous working directory. Pass this to another chdir() to restore the directory. On failure, returns an empty string. Example: >vim let save_dir = chdir(newdir) if save_dir != "" " ... do some work call chdir(save_dir) endif ]=], name = 'chdir', params = { { 'dir', 'string' } }, returns = 'string', signature = 'chdir({dir})', }, cindent = { args = 1, base = 1, desc = [=[ Get the amount of indent for line {lnum} according the C indenting rules, as with 'cindent'. The indent is counted in spaces, the value of 'tabstop' is relevant. {lnum} is used just like in |getline()|. When {lnum} is invalid -1 is returned. See |C-indenting|. ]=], name = 'cindent', params = { { 'lnum', 'integer' } }, returns = 'integer', signature = 'cindent({lnum})', }, clearmatches = { args = { 0, 1 }, base = 1, desc = [=[ Clears all matches previously defined for the current window by |matchadd()| and the |:match| commands. If {win} is specified, use the window with this number or window ID instead of the current window. ]=], name = 'clearmatches', params = { { 'win', 'any' } }, returns = false, signature = 'clearmatches([{win}])', }, col = { args = { 1, 2 }, base = 1, desc = [=[ The result is a Number, which is the byte index of the column position given with {expr}. The accepted positions are: . the cursor position $ the end of the cursor line (the result is the number of bytes in the cursor line plus one) 'x position of mark x (if the mark is not set, 0 is returned) v In Visual mode: the start of the Visual area (the cursor is the end). When not in Visual mode returns the cursor position. Differs from |'<| in that it's updated right away. Additionally {expr} can be [lnum, col]: a |List| with the line and column number. Most useful when the column is "$", to get the last column of a specific line. When "lnum" or "col" is out of range then col() returns zero. With the optional {winid} argument the values are obtained for that window instead of the current window. To get the line number use |line()|. To get both use |getpos()|. For the screen column position use |virtcol()|. For the character position use |charcol()|. Note that only marks in the current file can be used. Examples: >vim echo col(".") " column of cursor echo col("$") " length of cursor line plus one echo col("'t") " column of mark t echo col("'" .. markname) " column of mark markname mapping the cursor isn't moved, this can be used to obtain the column in Insert mode: >vim imap echo col(".").."\n" ]=], name = 'col', params = { { 'expr', 'any' }, { 'winid', 'integer' } }, returns = 'integer', signature = 'col({expr} [, {winid}])', }, complete = { args = 2, base = 2, desc = [=[ Set the matches for Insert mode completion. Can only be used in Insert mode. You need to use a mapping with CTRL-R = (see |i_CTRL-R|). It does not work after CTRL-O or with an expression mapping. {startcol} is the byte offset in the line where the completed text start. The text up to the cursor is the original text that will be replaced by the matches. Use col('.') for an empty string. "col('.') - 1" will replace one character by a match. {matches} must be a |List|. Each |List| item is one match. See |complete-items| for the kind of items that are possible. "longest" in 'completeopt' is ignored. Note that the after calling this function you need to avoid inserting anything that would cause completion to stop. The match can be selected with CTRL-N and CTRL-P as usual with Insert mode completion. The popup menu will appear if specified, see |ins-completion-menu|. Example: >vim inoremap =ListMonths() func ListMonths() call complete(col('.'), ['January', 'February', 'March', \ 'April', 'May', 'June', 'July', 'August', 'September', \ 'October', 'November', 'December']) return '' endfunc or keys) inserted Inserted string. [NOT IMPLEMENTED YET] *complete_info_mode* mode values are: "" Not in completion mode "keyword" Keyword completion |i_CTRL-X_CTRL-N| "ctrl_x" Just pressed CTRL-X |i_CTRL-X| "scroll" Scrolling with |i_CTRL-X_CTRL-E| or |i_CTRL-X_CTRL-Y| "whole_line" Whole lines |i_CTRL-X_CTRL-L| "files" File names |i_CTRL-X_CTRL-F| "tags" Tags |i_CTRL-X_CTRL-]| "path_defines" Definition completion |i_CTRL-X_CTRL-D| "path_patterns" Include completion |i_CTRL-X_CTRL-I| "dictionary" Dictionary |i_CTRL-X_CTRL-K| "thesaurus" Thesaurus |i_CTRL-X_CTRL-T| "cmdline" Vim Command line |i_CTRL-X_CTRL-V| "function" User defined completion |i_CTRL-X_CTRL-U| "omni" Omni completion |i_CTRL-X_CTRL-O| "spell" Spelling suggestions |i_CTRL-X_s| "eval" |complete()| completion "unknown" Other internal modes If the optional {what} list argument is supplied, then only the items listed in {what} are returned. Unsupported items in {what} are silently ignored. To get the position and size of the popup menu, see |pum_getpos()|. It's also available in |v:event| during the |CompleteChanged| event. Returns an empty |Dictionary| on error. Examples: >vim " Get all items call complete_info() " Get only 'mode' call complete_info(['mode']) " Get only 'mode' and 'pum_visible' call complete_info(['mode', 'pum_visible']) ]=], name = 'complete_info', params = { { 'what', 'any' } }, returns = 'table', signature = 'complete_info([{what}])', }, confirm = { args = { 1, 4 }, base = 1, desc = [=[ confirm() offers the user a dialog, from which a choice can be made. It returns the number of the choice. For the first choice this is 1. {msg} is displayed in a dialog with {choices} as the alternatives. When {choices} is missing or empty, "&OK" is used (and translated). {msg} is a String, use '\n' to include a newline. Only on some systems the string is wrapped when it doesn't fit. {choices} is a String, with the individual choices separated by '\n', e.g. >vim confirm("Save changes?", "&Yes\n&No\n&Cancel") vim confirm("file has been modified", "&Save\nSave &All") , CTRL-C, or another valid interrupt key, confirm() returns 0. An example: >vim let choice = confirm("What do you want?", \ "&Apples\n&Oranges\n&Bananas", 2) if choice == 0 echo "make up your mind!" elseif choice == 3 echo "tasteful" else echo "I prefer bananas myself." endif vim echo cos(100) < 0.862319 >vim echo cos(-4.01) < -0.646043 ]=], float_func = 'cos', name = 'cos', params = { { 'expr', 'any' } }, returns = 'number', signature = 'cos({expr})', }, cosh = { args = 1, base = 1, desc = [=[ Return the hyperbolic cosine of {expr} as a |Float| in the range [1, inf]. {expr} must evaluate to a |Float| or a |Number|. Returns 0.0 if {expr} is not a |Float| or a |Number|. Examples: >vim echo cosh(0.5) < 1.127626 >vim echo cosh(-0.5) < -1.127626 ]=], float_func = 'cosh', name = 'cosh', params = { { 'expr', 'any' } }, returns = 'number', signature = 'cosh({expr})', }, count = { args = { 2, 4 }, base = 1, tags = { 'E706' }, desc = [=[ Return the number of times an item with value {expr} appears in |String|, |List| or |Dictionary| {comp}. If {start} is given then start with the item with this index. {start} can only be used with a |List|. When {ic} is given and it's |TRUE| then case is ignored. When {comp} is a string then the number of not overlapping occurrences of {expr} is returned. Zero is returned when {expr} is an empty string. ]=], name = 'count', params = { { 'comp', 'any' }, { 'expr', 'any' }, { 'ic', 'any' }, { 'start', 'any' } }, returns = 'integer', signature = 'count({comp}, {expr} [, {ic} [, {start}]])', }, ctxget = { args = { 0, 1 }, desc = [=[ Returns a |Dictionary| representing the |context| at {index} from the top of the |context-stack| (see |context-dict|). If {index} is not given, it is assumed to be 0 (i.e.: top). ]=], name = 'ctxget', params = { { 'index', 'any' } }, returns = 'table', signature = 'ctxget([{index}])', }, ctxpop = { desc = [=[ Pops and restores the |context| at the top of the |context-stack|. ]=], name = 'ctxpop', params = {}, signature = 'ctxpop()', }, ctxpush = { args = { 0, 1 }, desc = [=[ Pushes the current editor state (|context|) on the |context-stack|. If {types} is given and is a |List| of |String|s, it specifies which |context-types| to include in the pushed context. Otherwise, all context types are included. ]=], name = 'ctxpush', params = { { 'types', 'any' } }, signature = 'ctxpush([{types}])', }, ctxset = { args = { 1, 2 }, desc = [=[ Sets the |context| at {index} from the top of the |context-stack| to that represented by {context}. {context} is a Dictionary with context data (|context-dict|). If {index} is not given, it is assumed to be 0 (i.e.: top). ]=], name = 'ctxset', params = { { 'context', 'any' }, { 'index', 'any' } }, signature = 'ctxset({context} [, {index}])', }, ctxsize = { desc = [=[ Returns the size of the |context-stack|. ]=], name = 'ctxsize', params = {}, signature = 'ctxsize()', }, cursor = { args = { 1, 3 }, base = 1, name = 'cursor', params = { { 'lnum', 'integer' }, { 'col', 'integer' }, { 'off', 'any' } }, signature = 'cursor({lnum}, {col} [, {off}])', }, cursor__1 = { args = { 1, 3 }, base = 1, desc = [=[ Positions the cursor at the column (byte count) {col} in the line {lnum}. The first column is one. When there is one argument {list} this is used as a |List| with two, three or four item: [{lnum}, {col}] [{lnum}, {col}, {off}] [{lnum}, {col}, {off}, {curswant}] This is like the return value of |getpos()| or |getcurpos()|, but without the first item. To position the cursor using {col} as the character count, use |setcursorcharpos()|. Does not change the jumplist. {lnum} is used like with |getline()|, except that if {lnum} is zero, the cursor will stay in the current line. If {lnum} is greater than the number of lines in the buffer, the cursor will be positioned at the last line in the buffer. If {col} is greater than the number of bytes in the line, the cursor will be positioned at the last character in the line. If {col} is zero, the cursor will stay in the current column. If {curswant} is given it is used to set the preferred column for vertical movement. Otherwise {col} is used. When 'virtualedit' is used {off} specifies the offset in screen columns from the start of the character. E.g., a position within a or after the last character. Returns 0 when the position could be set, -1 otherwise. ]=], name = 'cursor', params = { { 'list', 'any' } }, signature = 'cursor({list})', }, debugbreak = { args = { 1, 1 }, base = 1, desc = [=[ Specifically used to interrupt a program being debugged. It will cause process {pid} to get a SIGTRAP. Behavior for other processes is undefined. See |terminal-debug|. (Sends a SIGINT to a process {pid} other than MS-Windows) Returns |TRUE| if successfully interrupted the program. Otherwise returns |FALSE|. ]=], name = 'debugbreak', params = { { 'pid', 'any' } }, signature = 'debugbreak({pid})', }, deepcopy = { args = { 1, 2 }, base = 1, tags = { 'E698' }, desc = [=[ Make a copy of {expr}. For Numbers and Strings this isn't different from using {expr} directly. When {expr} is a |List| a full copy is created. This means that the original |List| can be changed without changing the copy, and vice versa. When an item is a |List|, a copy for it is made, recursively. Thus changing an item in the copy does not change the contents of the original |List|. When {noref} is omitted or zero a contained |List| or |Dictionary| is only copied once. All references point to this single copy. With {noref} set to 1 every occurrence of a |List| or |Dictionary| results in a new copy. This also means that a cyclic reference causes deepcopy() to fail. *E724* Nesting is possible up to 100 levels. When there is an item that refers back to a higher level making a deep copy with {noref} set to 1 will fail. Also see |copy()|. ]=], name = 'deepcopy', params = { { 'expr', 'any' }, { 'noref', 'any' } }, signature = 'deepcopy({expr} [, {noref}])', }, delete = { args = { 1, 2 }, base = 1, desc = [=[ Without {flags} or with {flags} empty: Deletes the file by the name {fname}. This also works when {fname} is a symbolic link. The symbolic link itself is deleted, not what it points to. When {flags} is "d": Deletes the directory by the name {fname}. This fails when directory {fname} is not empty. When {flags} is "rf": Deletes the directory by the name {fname} and everything in it, recursively. BE CAREFUL! Note: on MS-Windows it is not possible to delete a directory that is being used. The result is a Number, which is 0/false if the delete operation was successful and -1/true when the deletion failed or partly failed. ]=], name = 'delete', params = { { 'fname', 'string' }, { 'flags', 'string' } }, returns = 'integer', signature = 'delete({fname} [, {flags}])', }, deletebufline = { args = { 2, 3 }, base = 1, desc = [=[ Delete lines {first} to {last} (inclusive) from buffer {buf}. If {last} is omitted then delete line {first} only. On success 0 is returned, on failure 1 is returned. This function works only for loaded buffers. First call |bufload()| if needed. For the use of {buf}, see |bufname()| above. {first} and {last} are used like with |getline()|. Note that when using |line()| this refers to the current buffer. Use "$" to refer to the last line in buffer {buf}. ]=], name = 'deletebufline', params = { { 'buf', 'any' }, { 'first', 'any' }, { 'last', 'any' } }, signature = 'deletebufline({buf}, {first} [, {last}])', }, dictwatcheradd = { args = 3, desc = [=[ Adds a watcher to a dictionary. A dictionary watcher is identified by three components: - A dictionary({dict}); - A key pattern({pattern}). - A function({callback}). After this is called, every change on {dict} and on keys matching {pattern} will result in {callback} being invoked. For example, to watch all global variables: >vim silent! call dictwatcherdel(g:, '*', 'OnDictChanged') function! OnDictChanged(d,k,z) echomsg string(a:k) string(a:z) endfunction call dictwatcheradd(g:, '*', 'OnDictChanged') < For now {pattern} only accepts very simple patterns that can contain a "*" at the end of the string, in which case it will match every key that begins with the substring before the "*". That means if "*" is not the last character of {pattern}, only keys that are exactly equal as {pattern} will be matched. The {callback} receives three arguments: - The dictionary being watched. - The key which changed. - A dictionary containing the new and old values for the key. The type of change can be determined by examining the keys present on the third argument: - If contains both `old` and `new`, the key was updated. - If it contains only `new`, the key was added. - If it contains only `old`, the key was deleted. This function can be used by plugins to implement options with validation and parsing logic. ]=], name = 'dictwatcheradd', params = { { 'dict', 'any' }, { 'pattern', 'any' }, { 'callback', 'any' } }, signature = 'dictwatcheradd({dict}, {pattern}, {callback})', }, dictwatcherdel = { args = 3, desc = [=[ Removes a watcher added with |dictwatcheradd()|. All three arguments must match the ones passed to |dictwatcheradd()| in order for the watcher to be successfully deleted. ]=], name = 'dictwatcherdel', params = { { 'dict', 'any' }, { 'pattern', 'any' }, { 'callback', 'any' } }, signature = 'dictwatcherdel({dict}, {pattern}, {callback})', }, did_filetype = { desc = [=[ Returns |TRUE| when autocommands are being executed and the FileType event has been triggered at least once. Can be used to avoid triggering the FileType event again in the scripts that detect the file type. |FileType| Returns |FALSE| when `:setf FALLBACK` was used. When editing another file, the counter is reset, thus this really checks if the FileType event has been triggered for the current buffer. This allows an autocommand that starts editing another buffer to set 'filetype' and load a syntax file. ]=], fast = true, name = 'did_filetype', params = {}, signature = 'did_filetype()', }, diff_filler = { args = 1, base = 1, desc = [=[ Returns the number of filler lines above line {lnum}. These are the lines that were inserted at this point in another diff'ed window. These filler lines are shown in the display but don't exist in the buffer. {lnum} is used like with |getline()|. Thus "." is the current line, "'m" mark m, etc. Returns 0 if the current window is not in diff mode. ]=], name = 'diff_filler', params = { { 'lnum', 'integer' } }, signature = 'diff_filler({lnum})', }, diff_hlID = { args = 2, base = 1, desc = [=[ Returns the highlight ID for diff mode at line {lnum} column {col} (byte index). When the current line does not have a diff change zero is returned. {lnum} is used like with |getline()|. Thus "." is the current line, "'m" mark m, etc. {col} is 1 for the leftmost column, {lnum} is 1 for the first line. The highlight ID can be used with |synIDattr()| to obtain syntax information about the highlighting. ]=], name = 'diff_hlID', params = { { 'lnum', 'integer' }, { 'col', 'integer' } }, signature = 'diff_hlID({lnum}, {col})', }, digraph_get = { args = 1, base = 1, tags = { 'E1214' }, desc = [=[ Return the digraph of {chars}. This should be a string with exactly two characters. If {chars} are not just two characters, or the digraph of {chars} does not exist, an error is given and an empty string is returned. Also see |digraph_getlist()|. Examples: >vim " Get a built-in digraph echo digraph_get('00') " Returns '∞' " Get a user-defined digraph call digraph_set('aa', 'あ') echo digraph_get('aa') " Returns 'あ' < ]=], name = 'digraph_get', params = { { 'chars', 'any' } }, signature = 'digraph_get({chars})', }, digraph_getlist = { args = { 0, 1 }, base = 1, desc = [=[ Return a list of digraphs. If the {listall} argument is given and it is TRUE, return all digraphs, including the default digraphs. Otherwise, return only user-defined digraphs. Also see |digraph_get()|. Examples: >vim " Get user-defined digraphs echo digraph_getlist() " Get all the digraphs, including default digraphs echo digraph_getlist(1) < ]=], name = 'digraph_getlist', params = { { 'listall', 'any' } }, signature = 'digraph_getlist([{listall}])', }, digraph_set = { args = 2, base = 1, desc = [=[ Add digraph {chars} to the list. {chars} must be a string with two characters. {digraph} is a string with one UTF-8 encoded character. *E1215* Be careful, composing characters are NOT ignored. This function is similar to |:digraphs| command, but useful to add digraphs start with a white space. The function result is v:true if |digraph| is registered. If this fails an error message is given and v:false is returned. If you want to define multiple digraphs at once, you can use |digraph_setlist()|. Example: >vim call digraph_set(' ', 'あ') < Can be used as a |method|: >vim GetString()->digraph_set('あ') < ]=], name = 'digraph_set', params = { { 'chars', 'any' }, { 'digraph', 'any' } }, signature = 'digraph_set({chars}, {digraph})', }, digraph_setlist = { args = 1, base = 1, desc = [=[ Similar to |digraph_set()| but this function can add multiple digraphs at once. {digraphlist} is a list composed of lists, where each list contains two strings with {chars} and {digraph} as in |digraph_set()|. *E1216* Example: >vim call digraph_setlist([['aa', 'あ'], ['ii', 'い']]) < It is similar to the following: >vim for [chars, digraph] in [['aa', 'あ'], ['ii', 'い']] call digraph_set(chars, digraph) endfor vim GetList()->digraph_setlist() < ]=], name = 'digraph_setlist', params = { { 'digraphlist', 'any' } }, signature = 'digraph_setlist({digraphlist})', }, empty = { args = 1, base = 1, desc = [=[ Return the Number 1 if {expr} is empty, zero otherwise. - A |List| or |Dictionary| is empty when it does not have any items. - A |String| is empty when its length is zero. - A |Number| and |Float| are empty when their value is zero. - |v:false| and |v:null| are empty, |v:true| is not. - A |Blob| is empty when its length is zero. ]=], name = 'empty', params = { { 'expr', 'any' } }, signature = 'empty({expr})', }, environ = { desc = [=[ Return all of environment variables as dictionary. You can check if an environment variable exists like this: >vim echo has_key(environ(), 'HOME') vim echo index(keys(environ()), 'HOME', 0, 1) != -1 < ]=], fast = true, name = 'environ', params = {}, signature = 'environ()', }, escape = { args = 2, base = 1, desc = [=[ Escape the characters in {chars} that occur in {string} with a backslash. Example: >vim echo escape('c:\program files\vim', ' \') c:\\program\ files\\vim vim echo execute('echon "foo"') < foo >vim echo execute(['echon "foo"', 'echon "bar"']) < foobar The optional {silent} argument can have these values: "" no `:silent` used "silent" `:silent` used "silent!" `:silent!` used The default is "silent". Note that with "silent!", unlike `:redir`, error messages are dropped. To get a list of lines use `split()` on the result: >vim execute('args')->split("\n") vim let l = [1, 2, 3] echo exists("l[5]") < 0 >vim echo exists("l[xx]") < E121: Undefined variable: xx 0 &option-name Vim option (only checks if it exists, not if it really works) +option-name Vim option that works. $ENVNAME environment variable (could also be done by comparing with an empty string) `*funcname` built-in function (see |functions|) or user defined function (see |user-function|). Also works for a variable that is a Funcref. :cmdname Ex command: built-in command, user command or command modifier |:command|. Returns: 1 for match with start of a command 2 full match with a command 3 matches several user commands To check for a supported command always check the return value to be 2. :2match The |:2match| command. :3match The |:3match| command (but you probably should not use it, it is reserved for internal usage) #event autocommand defined for this event #event#pattern autocommand defined for this event and pattern (the pattern is taken literally and compared to the autocommand patterns character by character) #group autocommand group exists #group#event autocommand defined for this group and event. #group#event#pattern autocommand defined for this group, event and pattern. ##event autocommand for this event is supported. Examples: >vim echo exists("&mouse") echo exists("$HOSTNAME") echo exists("*strftime") echo exists("*s:MyFunc") echo exists("*MyFunc") echo exists("bufcount") echo exists(":Make") echo exists("#CursorHold") echo exists("#BufReadPre#*.gz") echo exists("#filetypeindent") echo exists("#filetypeindent#FileType") echo exists("#filetypeindent#FileType#*") echo exists("##ColorScheme") vim echo exists(":make") vim echo exists(":make install") vim echo exists(bufcount) vim echo exp(2) < 7.389056 >vim echo exp(-1) < 0.367879 ]=], float_func = 'exp', name = 'exp', params = { { 'expr', 'any' } }, signature = 'exp({expr})', }, expand = { args = { 1, 3 }, base = 1, desc = [=[ Expand wildcards and the following special keywords in {string}. 'wildignorecase' applies. If {list} is given and it is |TRUE|, a List will be returned. Otherwise the result is a String and when there are several matches, they are separated by characters. If the expansion fails, the result is an empty string. A name for a non-existing file is not included, unless {string} does not start with '%', '#' or '<', see below. When {string} starts with '%', '#' or '<', the expansion is done like for the |cmdline-special| variables with their associated modifiers. Here is a short overview: % current file name # alternate file name #n alternate file name n file name under the cursor autocmd file name autocmd buffer number (as a String!) autocmd matched name C expression under the cursor sourced script file or function name sourced script line number or function line number script file line number, also when in a function "123_" where "123" is the current script ID ||