diff options
| author | Josh Rahm <joshuarahm@gmail.com> | 2024-11-19 22:57:13 +0000 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2024-11-19 22:57:13 +0000 |
| commit | 9be89f131f87608f224f0ee06d199fcd09d32176 (patch) | |
| tree | 11022dcfa9e08cb4ac5581b16734196128688d48 /runtime/doc | |
| parent | ff7ed8f586589d620a806c3758fac4a47a8e7e15 (diff) | |
| parent | 88085c2e80a7e3ac29aabb6b5420377eed99b8b6 (diff) | |
| download | rneovim-9be89f131f87608f224f0ee06d199fcd09d32176.tar.gz rneovim-9be89f131f87608f224f0ee06d199fcd09d32176.tar.bz2 rneovim-9be89f131f87608f224f0ee06d199fcd09d32176.zip | |
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'runtime/doc')
67 files changed, 5741 insertions, 1360 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 2aa147770d..dee0324a5b 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -42,9 +42,9 @@ The RPC API is like a more powerful version of Vim's "clientserver" feature. CONNECTING *rpc-connecting* See |channel-intro| for various ways to open a channel. Channel-opening -functions take an `rpc` key in the options dictionary. RPC channels can also -be opened by other processes connecting to TCP/IP sockets or named pipes -listened to by Nvim. +functions take an `rpc` key in the options dict. RPC channels can also be +opened by other processes connecting to TCP/IP sockets or named pipes listened +to by Nvim. Nvim creates a default RPC socket at |startup|, given by |v:servername|. To start with a TCP/IP socket instead, use |--listen| with a TCP-style address: > @@ -108,9 +108,9 @@ Basic types ~ Integer (signed 64-bit integer) int64_t Float (IEEE 754 double precision) double String {char* data, size_t size} struct - Array - Dictionary (msgpack: map) - Object + Array kvec + Dict (msgpack: map) kvec + Object any of the above < Note: - Empty Array is accepted as a valid Dictionary parameter. @@ -708,12 +708,12 @@ nvim_eval_statusline({str}, {opts}) *nvim_eval_statusline()* line number instead of statusline. Return: ~ - Dictionary containing statusline information, with these keys: + Dict containing statusline information, with these keys: • str: (string) Characters that will be displayed on the statusline. • width: (number) Display width of the statusline. • highlights: Array containing highlight information of the statusline. Only included when the "highlights" key in {opts} is - true. Each element of the array is a |Dictionary| with these keys: + true. Each element of the array is a |Dict| with these keys: • start: (number) Byte index (0-based) of first character that uses the highlight. • group: (string) Name of highlight group. @@ -763,7 +763,7 @@ nvim_feedkeys({keys}, {mode}, {escape_ks}) *nvim_feedkeys()* nvim_get_api_info() *nvim_get_api_info()* Returns a 2-tuple (Array), where item 0 is the current channel id and item - 1 is the |api-metadata| map (Dictionary). + 1 is the |api-metadata| map (Dict). Attributes: ~ |api-fast| @@ -779,7 +779,7 @@ nvim_get_chan_info({chan}) *nvim_get_chan_info()* • {chan} channel_id, or 0 for current channel Return: ~ - Dictionary describing a channel, with these keys: + Channel info dict with these keys: • "id" Channel id. • "argv" (optional) Job arguments list. • "stream" Stream underlying the channel. @@ -792,11 +792,11 @@ nvim_get_chan_info({chan}) *nvim_get_chan_info()* • "terminal" |terminal| instance interprets ASCII sequences. • "rpc" |RPC| communication on the channel is active. • "pty" (optional) Name of pseudoterminal. On a POSIX system this is a - device path like "/dev/pts/1". If the name is unknown, the key will - still be present if a pty is used (e.g. for conpty on Windows). - • "buffer" (optional) Buffer with connected |terminal| instance. + device path like "/dev/pts/1". If unknown, the key will still be + present if a pty is used (e.g. for conpty on Windows). + • "buffer" (optional) Buffer connected to |terminal| instance. • "client" (optional) Info about the peer (client on the other end of - the RPC channel), if provided by it via |nvim_set_client_info()|. + the RPC channel), which it provided via |nvim_set_client_info()|. nvim_get_color_by_name({name}) *nvim_get_color_by_name()* Returns the 24-bit RGB value of a |nvim_get_color_map()| color name or @@ -939,7 +939,7 @@ nvim_get_mode() *nvim_get_mode()* |api-fast| Return: ~ - Dictionary { "mode": String, "blocking": Boolean } + Dict { "mode": String, "blocking": Boolean } nvim_get_proc({pid}) *nvim_get_proc()* Gets info describing process `pid`. @@ -954,11 +954,11 @@ nvim_get_proc_children({pid}) *nvim_get_proc_children()* Array of child process ids, empty if process not found. nvim_get_runtime_file({name}, {all}) *nvim_get_runtime_file()* - Find files in runtime directories + Finds files in runtime directories, in 'runtimepath' order. "name" can contain wildcards. For example - nvim_get_runtime_file("colors/*.vim", true) will return all color scheme - files. Always use forward slashes (/) in the search pattern for + `nvim_get_runtime_file("colors/*.{vim,lua}", true)` will return all color + scheme files. Always use forward slashes (/) in the search pattern for subdirectories regardless of platform. It is not an error to not find any files. An empty array is returned then. @@ -996,6 +996,9 @@ nvim_input({keys}) *nvim_input()* input buffer and the call is non-blocking (input is processed asynchronously by the eventloop). + To input blocks of text, |nvim_paste()| is much faster and should be + preferred. + On execution error: does not fail, but updates v:errmsg. Note: ~ @@ -1148,21 +1151,35 @@ nvim_out_write({str}) *nvim_out_write()* • {str} Message nvim_paste({data}, {crlf}, {phase}) *nvim_paste()* - Pastes at cursor, in any mode. + Pastes at cursor (in any mode), and sets "redo" so dot (|.|) will repeat + the input. UIs call this to implement "paste", but it's also intended for + use by scripts to input large, dot-repeatable blocks of text (as opposed + to |nvim_input()| which is subject to mappings/events and is thus much + slower). - Invokes the `vim.paste` handler, which handles each mode appropriately. - Sets redo/undo. Faster than |nvim_input()|. Lines break at LF ("\n"). + Invokes the |vim.paste()| handler, which handles each mode appropriately. Errors ('nomodifiable', `vim.paste()` failure, …) are reflected in `err` but do not affect the return value (which is strictly decided by - `vim.paste()`). On error, subsequent calls are ignored ("drained") until - the next paste is initiated (phase 1 or -1). + `vim.paste()`). On error or cancel, subsequent calls are ignored + ("drained") until the next paste is initiated (phase 1 or -1). + + Useful in mappings and scripts to insert multiline text. Example: >lua + vim.keymap.set('n', 'x', function() + vim.api.nvim_paste([[ + line1 + line2 + line3 + ]], false, -1) + end, { buffer = true }) +< Attributes: ~ not allowed when |textlock| is active Parameters: ~ - • {data} Multiline input. May be binary (containing NUL bytes). + • {data} Multiline input. Lines break at LF ("\n"). May be binary + (containing NUL bytes). • {crlf} Also break lines at CR and CRLF. • {phase} -1: paste in a single call (i.e. without streaming). To "stream" a paste, call `nvim_paste` sequentially with these @@ -1173,10 +1190,11 @@ nvim_paste({data}, {crlf}, {phase}) *nvim_paste()* Return: ~ • true: Client may continue pasting. - • false: Client must cancel the paste. + • false: Client should cancel the paste. nvim_put({lines}, {type}, {after}, {follow}) *nvim_put()* - Puts text at cursor, in any mode. + Puts text at cursor, in any mode. For dot-repeatable input, use + |nvim_paste()|. Compare |:put| and |p| which are always linewise. @@ -1249,8 +1267,7 @@ nvim_set_client_info({name}, {version}, {type}, {methods}, {attributes}) Parameters: ~ • {name} Short name for the connected client - • {version} Dictionary describing the version, with these (optional) - keys: + • {version} Dict describing the version, with these (optional) keys: • "major" major version (defaults to 0 if not set, for no release yet) • "minor" minor version @@ -1285,6 +1302,7 @@ nvim_set_client_info({name}, {version}, {type}, {methods}, {attributes}) inclusive. • {attributes} Arbitrary string:string map of informal client properties. Suggested keys: + • "pid": Process id. • "website": Client homepage URL (e.g. GitHub repository) • "license": License description ("Apache 2", "GPLv3", @@ -1474,7 +1492,7 @@ nvim__complete_set({index}, {opts}) *nvim__complete_set()* • info: (string) info text. Return: ~ - Dictionary containing these keys: + Dict containing these keys: • winid: (number) floating window id • bufnr: (number) buffer id in floating window @@ -1516,14 +1534,14 @@ nvim__id_array({arr}) *nvim__id_array()* Return: ~ its argument. -nvim__id_dictionary({dct}) *nvim__id_dictionary()* - Returns dictionary given as argument. +nvim__id_dict({dct}) *nvim__id_dict()* + Returns dict given as argument. This API function is used for testing. One should not rely on its presence in plugins. Parameters: ~ - • {dct} Dictionary to return. + • {dct} Dict to return. Return: ~ its argument. @@ -1594,7 +1612,7 @@ nvim_call_dict_function({dict}, {fn}, {args}) On execution error: fails with Vimscript error, updates v:errmsg. Parameters: ~ - • {dict} Dictionary, or String evaluating to a Vimscript |self| dict + • {dict} Dict, or String evaluating to a Vimscript |self| dict • {fn} Name of the function defined on the Vimscript dict • {args} Function arguments packed in an Array @@ -1628,7 +1646,7 @@ nvim_command({command}) *nvim_command()* • {command} Ex command string nvim_eval({expr}) *nvim_eval()* - Evaluates a Vimscript |expression|. Dictionaries and Lists are recursively + Evaluates a Vimscript |expression|. Dicts and Lists are recursively expanded. On execution error: fails with Vimscript error, updates v:errmsg. @@ -1655,7 +1673,7 @@ nvim_exec2({src}, {opts}) *nvim_exec2()* return all (non-error, non-shell |:!|) output. Return: ~ - Dictionary containing information about execution, with these keys: + Dict containing information about execution, with these keys: • output: (string|nil) Output if `opts.output` is true. See also: ~ @@ -1692,9 +1710,9 @@ nvim_parse_expression({expr}, {flags}, {highlight}) region [start_col, end_col)). Return: ~ - • AST: top-level dictionary with these keys: - • "error": Dictionary with error, present only if parser saw some - error. Contains the following keys: + • AST: top-level dict with these keys: + • "error": Dict with error, present only if parser saw some error. + Contains the following keys: • "message": String, error message in printf format, translated. Must contain exactly one "%.*s". • "arg": String, error message argument. @@ -1702,7 +1720,7 @@ nvim_parse_expression({expr}, {flags}, {highlight}) that should be equal to the length of expr string. ("Successfully parsed" here means "participated in AST creation", not "till the first error".) - • "ast": AST, either nil or a dictionary with these keys: + • "ast": AST, either nil or a dict with these keys: • "type": node type, one of the value names from ExprASTNodeType stringified without "kExprNode" prefix. • "start": a pair `[line, column]` describing where node is @@ -1778,8 +1796,8 @@ nvim_buf_get_commands({buffer}, {opts}) *nvim_buf_get_commands()* nvim_cmd({cmd}, {opts}) *nvim_cmd()* Executes an Ex command. - Unlike |nvim_command()| this command takes a structured Dictionary instead - of a String. This allows for easier construction and manipulation of an Ex + Unlike |nvim_command()| this command takes a structured Dict instead of a + String. This allows for easier construction and manipulation of an Ex command. This also allows for things such as having spaces inside a command argument, expanding filenames in a command that otherwise doesn't expand filenames, etc. Command arguments may also be Number, Boolean or @@ -1793,8 +1811,8 @@ nvim_cmd({cmd}, {opts}) *nvim_cmd()* On execution error: fails with Vimscript error, updates v:errmsg. Parameters: ~ - • {cmd} Command to execute. Must be a Dictionary that can contain the - same values as the return value of |nvim_parse_cmd()| except + • {cmd} Command to execute. Must be a Dict that can contain the same + values as the return value of |nvim_parse_cmd()| except "addr", "nargs" and "nextcmd" which are ignored if provided. All values except for "cmd" are optional. • {opts} Optional parameters. @@ -1896,7 +1914,7 @@ nvim_parse_cmd({str}, {opts}) *nvim_parse_cmd()* • {opts} Optional parameters. Reserved for future use. Return: ~ - Dictionary containing command information, with these keys: + Dict containing command information, with these keys: • cmd: (string) Command name. • range: (array) (optional) Command range (<line1> <line2>). Omitted if command doesn't accept a range. Otherwise, has no elements if no @@ -1913,15 +1931,15 @@ nvim_parse_cmd({str}, {opts}) *nvim_parse_cmd()* • nargs: (string) Value of |:command-nargs|. • nextcmd: (string) Next command if there are multiple commands separated by a |:bar|. Empty if there isn't a next command. - • magic: (dictionary) Which characters have special meaning in the - command arguments. + • magic: (dict) Which characters have special meaning in the command + arguments. • file: (boolean) The command expands filenames. Which means characters such as "%", "#" and wildcards are expanded. • bar: (boolean) The "|" character is treated as a command separator and the double quote character (") is treated as the start of a comment. - • mods: (dictionary) |:command-modifiers|. - • filter: (dictionary) |:filter|. + • mods: (dict) |:command-modifiers|. + • filter: (dict) |:filter|. • pattern: (string) Filter pattern. Empty string if there is no filter. • force: (boolean) Whether filter is inverted or not. @@ -1958,11 +1976,11 @@ Options Functions *api-options* nvim_get_all_options_info() *nvim_get_all_options_info()* Gets the option information for all options. - The dictionary has the full option names as keys and option metadata - dictionaries as detailed at |nvim_get_option_info2()|. + The dict has the full option names as keys and option metadata dicts as + detailed at |nvim_get_option_info2()|. Return: ~ - dictionary of all options + dict of all options See also: ~ • |nvim_get_commands()| @@ -1970,7 +1988,7 @@ nvim_get_all_options_info() *nvim_get_all_options_info()* nvim_get_option_info2({name}, {opts}) *nvim_get_option_info2()* Gets the option information for one option from arbitrary buffer or window - Resulting dictionary has keys: + Resulting dict has keys: • name: Name of the option (like 'filetype') • shortname: Shortened name of the option (like 'ft') • type: type of option ("string", "number" or "boolean") @@ -2138,14 +2156,14 @@ nvim_buf_attach({buffer}, {send_buffer}, {opts}) *nvim_buf_attach()* • |api-buffer-updates-lua| nvim_buf_call({buffer}, {fun}) *nvim_buf_call()* - call a function with buffer as temporary current buffer + Call a function with buffer as temporary current buffer. This temporarily switches current buffer to "buffer". If the current - window already shows "buffer", the window is not switched If a window - inside the current tabpage (including a float) already shows the buffer - One of these windows will be set as current window temporarily. Otherwise - a temporary scratch window (called the "autocmd window" for historical - reasons) will be used. + window already shows "buffer", the window is not switched. If a window + inside the current tabpage (including a float) already shows the buffer, + then one of these windows will be set as current window temporarily. + Otherwise a temporary scratch window (called the "autocmd window" for + historical reasons) will be used. This is useful e.g. to call Vimscript functions that only work with the current buffer/window currently, like |termopen()|. @@ -2460,10 +2478,11 @@ nvim_buf_set_text({buffer}, {start_row}, {start_col}, {end_row}, {end_col}, `start_row = end_row = row` and `start_col = end_col = col`. To delete the text in a range, use `replacement = {}`. - Prefer |nvim_buf_set_lines()| if you are only adding or deleting entire - lines. - - Prefer |nvim_put()| if you want to insert text at the cursor position. + Note: ~ + • Prefer |nvim_buf_set_lines()| (for performance) to add or delete + entire lines. + • Prefer |nvim_paste()| or |nvim_put()| to insert (instead of replace) + text at cursor. Attributes: ~ not allowed when |textlock| is active @@ -2476,10 +2495,6 @@ nvim_buf_set_text({buffer}, {start_row}, {start_col}, {end_row}, {end_col}, • {end_col} Ending column (byte offset) on last line, exclusive • {replacement} Array of lines to use as replacement - See also: ~ - • |nvim_buf_set_lines()| - • |nvim_put()| - nvim_buf_set_var({buffer}, {name}, {value}) *nvim_buf_set_var()* Sets a buffer-scoped (b:) variable @@ -2758,8 +2773,6 @@ nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {opts}) • url: A URL to associate with this extmark. In the TUI, the OSC 8 control sequence is used to generate a clickable hyperlink to this URL. - • scoped: boolean (EXPERIMENTAL) enables "scoping" for the - extmark. See |nvim__win_add_ns()| Return: ~ Id of the created/updated extmark @@ -2802,7 +2815,7 @@ nvim_set_decoration_provider({ns_id}, {opts}) Note: this function should not be called often. Rather, the callbacks themselves can be used to throttle unneeded callbacks. the `on_start` callback can return `false` to disable the provider until the next redraw. - Similarly, return `false` in `on_win` will skip the `on_lines` calls for + Similarly, return `false` in `on_win` will skip the `on_line` calls for that window (but any extmarks set in `on_win` will still be used). A plugin managing multiple sources of decoration should ideally only set one provider, and merge the sources internally. You can use multiple `ns_id` @@ -2811,10 +2824,10 @@ nvim_set_decoration_provider({ns_id}, {opts}) Note: doing anything other than setting extmarks is considered experimental. Doing things like changing options are not explicitly forbidden, but is likely to have unexpected consequences (such as 100% CPU - consumption). doing `vim.rpcnotify` should be OK, but `vim.rpcrequest` is + consumption). Doing `vim.rpcnotify` should be OK, but `vim.rpcrequest` is quite dubious for the moment. - Note: It is not allowed to remove or update extmarks in 'on_line' + Note: It is not allowed to remove or update extmarks in `on_line` callbacks. Attributes: ~ @@ -2831,7 +2844,7 @@ nvim_set_decoration_provider({ns_id}, {opts}) ["buf", bufnr, tick] < • on_win: called when starting to redraw a specific window. > - ["win", winid, bufnr, topline, botline] + ["win", winid, bufnr, toprow, botrow] < • on_line: called for each buffer line being redrawn. (The interaction with fold lines is subject to change) > @@ -2841,41 +2854,26 @@ nvim_set_decoration_provider({ns_id}, {opts}) ["end", tick] < -nvim__win_add_ns({window}, {ns_id}) *nvim__win_add_ns()* +nvim__ns_get({ns_id}) *nvim__ns_get()* EXPERIMENTAL: this API will change in the future. - Scopes a namespace to the a window, so extmarks in the namespace will be - active only in the given window. + Get the properties for namespace Parameters: ~ - • {window} Window handle, or 0 for current window - • {ns_id} Namespace + • {ns_id} Namespace Return: ~ - true if the namespace was added, else false + Map defining the namespace properties, see |nvim__ns_set()| -nvim__win_del_ns({window}, {ns_id}) *nvim__win_del_ns()* +nvim__ns_set({ns_id}, {opts}) *nvim__ns_set()* EXPERIMENTAL: this API will change in the future. - Unscopes a namespace (un-binds it from the given scope). + Set some properties for namespace Parameters: ~ - • {window} Window handle, or 0 for current window - • {ns_id} the namespace to remove - - Return: ~ - true if the namespace was removed, else false - -nvim__win_get_ns({window}) *nvim__win_get_ns()* - EXPERIMENTAL: this API will change in the future. - - Gets the namespace scopes for a given window. - - Parameters: ~ - • {window} Window handle, or 0 for current window - - Return: ~ - a list of namespaces ids + • {ns_id} Namespace + • {opts} Optional parameters to set: + • wins: a list of windows to be scoped in ============================================================================== @@ -3097,7 +3095,7 @@ nvim_win_text_height({window}, {opts}) *nvim_win_text_height()* omitted include the whole line. Return: ~ - Dictionary containing text height information, with these keys: + Dict containing text height information, with these keys: • all: The total number of screen lines occupied by the range. • fill: The number of diff filler or virtual lines among them. @@ -3259,13 +3257,15 @@ nvim_open_win({buffer}, {enter}, {config}) *nvim_open_win()* < • title: Title (optional) in window border, string or list. List should consist of `[text, highlight]` tuples. If - string, the default highlight group is `FloatTitle`. + string, or a tuple lacks a highlight, the default + highlight group is `FloatTitle`. • title_pos: Title position. Must be set with `title` option. Value can be one of "left", "center", or "right". Default is `"left"`. • footer: Footer (optional) in window border, string or list. List should consist of `[text, highlight]` tuples. - If string, the default highlight group is `FloatFooter`. + If string, or a tuple lacks a highlight, the default + highlight group is `FloatFooter`. • footer_pos: Footer position. Must be set with `footer` option. Value can be one of "left", "center", or "right". Default is `"left"`. @@ -3419,7 +3419,7 @@ nvim_create_augroup({name}, {opts}) *nvim_create_augroup()* Parameters: ~ • {name} String: The name of the group - • {opts} Dictionary Parameters + • {opts} Dict Parameters • clear (bool) optional: defaults to true. Clear existing commands if the group already exists |autocmd-groups|. @@ -3538,7 +3538,7 @@ nvim_exec_autocmds({event}, {opts}) *nvim_exec_autocmds()* Parameters: ~ • {event} (String|Array) The event or events to execute - • {opts} Dictionary of autocommand options: + • {opts} Dict of autocommand options: • group (string|integer) optional: the autocommand group name or id to match against. |autocmd-groups|. • pattern (string|array) optional: defaults to "*" @@ -3574,7 +3574,7 @@ nvim_get_autocmds({opts}) *nvim_get_autocmds()* autocommands that match any combination of them. Parameters: ~ - • {opts} Dictionary with at least one of the following: + • {opts} Dict with at least one of the following: • group (string|integer): the autocommand group name or id to match against. • event (string|array): event or events to match against diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index ca816851dd..8e5e2628de 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -522,6 +522,11 @@ CursorMoved After the cursor was moved in Normal or Visual Careful: This is triggered very often, don't do anything that the user does not expect or that is slow. + *CursorMovedC* +CursorMovedC After the cursor was moved in the command + line. Be careful not to mess up the command + line, it may cause Vim to lock up. + <afile> expands to the |cmdline-char|. *CursorMovedI* CursorMovedI After the cursor was moved in Insert mode. Not triggered when the popup menu is visible. diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index ff7d5f9ce8..4c726f86d2 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -25,6 +25,12 @@ abs({expr}) *abs()* echo abs(-4) < 4 + Parameters: ~ + • {expr} (`number`) + + Return: ~ + (`number`) + acos({expr}) *acos()* Return the arc cosine of {expr} measured in radians, as a |Float| in the range of [0, pi]. @@ -38,6 +44,12 @@ acos({expr}) *acos()* echo acos(-0.5) < 2.094395 + Parameters: ~ + • {expr} (`number`) + + Return: ~ + (`number`) + add({object}, {expr}) *add()* Append the item {expr} to |List| or |Blob| {object}. Returns the resulting |List| or |Blob|. Examples: >vim @@ -49,6 +61,14 @@ add({object}, {expr}) *add()* Use |insert()| to add an item at another position. Returns 1 if {object} is not a |List| or a |Blob|. + Parameters: ~ + • {object} (`any`) + • {expr} (`any`) + + Return: ~ + (`any`) Resulting |List| or |Blob|, or 1 if {object} is not + a |List| or a |Blob|. + and({expr}, {expr}) *and()* Bitwise AND on the two arguments. The arguments are converted to a number. A List, Dict or Float argument causes an error. @@ -57,6 +77,13 @@ and({expr}, {expr}) *and()* let flag = and(bits, 0x80) < + Parameters: ~ + • {expr} (`number`) + • {expr1} (`number`) + + Return: ~ + (`integer`) + api_info() *api_info()* Returns Dictionary of |api-metadata|. @@ -64,6 +91,9 @@ api_info() *api_info()* lua vim.print(vim.fn.api_info()) < + Return: ~ + (`table`) + append({lnum}, {text}) *append()* When {text} is a |List|: Append each item of the |List| as a text line below line {lnum} in the current buffer. @@ -79,6 +109,13 @@ append({lnum}, {text}) *append()* let failed = append(0, ["Chapter 1", "the beginning"]) < + Parameters: ~ + • {lnum} (`integer`) + • {text} (`string|string[]`) + + Return: ~ + (`0|1`) + appendbufline({buf}, {lnum}, {text}) *appendbufline()* Like |append()| but append the text in buffer {expr}. @@ -100,6 +137,14 @@ appendbufline({buf}, {lnum}, {text}) *appendbufline()* < However, when {text} is an empty list then no error is given for an invalid {lnum}, since {lnum} isn't actually used. + Parameters: ~ + • {buf} (`integer|string`) + • {lnum} (`integer`) + • {text} (`string`) + + Return: ~ + (`0|1`) + argc([{winid}]) *argc()* The result is the number of files in the argument list. See |arglist|. @@ -110,10 +155,19 @@ argc([{winid}]) *argc()* list is used: either the window number or the window ID. Returns -1 if the {winid} argument is invalid. + Parameters: ~ + • {winid} (`integer?`) + + Return: ~ + (`integer`) + argidx() *argidx()* The result is the current index in the argument list. 0 is the first file. argc() - 1 is the last one. See |arglist|. + Return: ~ + (`integer`) + arglistid([{winnr} [, {tabnr}]]) *arglistid()* Return the argument list ID. This is a number which identifies the argument list being used. Zero is used for the @@ -126,6 +180,13 @@ arglistid([{winnr} [, {tabnr}]]) *arglistid()* page. {winnr} can be the window number or the |window-ID|. + Parameters: ~ + • {winnr} (`integer?`) + • {tabnr} (`integer?`) + + Return: ~ + (`integer`) + argv([{nr} [, {winid}]]) *argv()* The result is the {nr}th file in the argument list. See |arglist|. "argv(0)" is the first one. Example: >vim @@ -145,6 +206,13 @@ argv([{nr} [, {winid}]]) *argv()* the argument list. Returns an empty List if the {winid} argument is invalid. + Parameters: ~ + • {nr} (`integer?`) + • {winid} (`integer?`) + + Return: ~ + (`string|string[]`) + asin({expr}) *asin()* Return the arc sine of {expr} measured in radians, as a |Float| in the range of [-pi/2, pi/2]. @@ -158,27 +226,48 @@ asin({expr}) *asin()* echo asin(-0.5) < -0.523599 + Parameters: ~ + • {expr} (`any`) + + Return: ~ + (`number`) + assert_beeps({cmd}) *assert_beeps()* 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|. + Parameters: ~ + • {cmd} (`string`) + + Return: ~ + (`0|1`) + assert_equal({expected}, {actual} [, {msg}]) *assert_equal()* 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. + {actual}". When {msg} is present it is prefixed to that, + along with the location of the assert when run from a script. 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') -< Will result in a string to be added to |v:errors|: - test.vim line 12: Expected 'foo' but got 'bar' ~ + call assert_equal('foo', 'bar', 'baz') +< Will add the following to |v:errors|: + test.vim line 12: baz: Expected 'foo' but got 'bar' ~ + + Parameters: ~ + • {expected} (`any`) + • {actual} (`any`) + • {msg} (`any?`) + + Return: ~ + (`0|1`) assert_equalfile({fname-one}, {fname-two}) *assert_equalfile()* When the files {fname-one} and {fname-two} do not contain @@ -187,6 +276,13 @@ assert_equalfile({fname-one}, {fname-two}) *assert_equalfile()* When {fname-one} or {fname-two} does not exist the error will mention that. + Parameters: ~ + • {fname-one} (`string`) + • {fname-two} (`string`) + + Return: ~ + (`0|1`) + assert_exception({error} [, {msg}]) *assert_exception()* When v:exception does not contain the string {error} an error message is added to |v:errors|. Also see |assert-return|. @@ -201,6 +297,13 @@ assert_exception({error} [, {msg}]) *assert_exception()* endtry < + Parameters: ~ + • {error} (`any`) + • {msg} (`any?`) + + Return: ~ + (`0|1`) + *assert_fails()* assert_fails({cmd} [, {error} [, {msg} [, {lnum} [, {context}]]]]) Run {cmd} and add an error message to |v:errors| if it does @@ -210,25 +313,25 @@ assert_fails({cmd} [, {error} [, {msg} [, {lnum} [, {context}]]]]) 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:') + call 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']) + call assert_fails('cmd', ['E987:.*expected bool']) < The second pattern, if present, is matched against the last reported error. To only match the last error use an empty string for the first error: >vim - assert_fails('cmd', ['', 'E987:']) + call 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. - + *E1115* 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. - + *E1116* 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. @@ -236,16 +339,34 @@ assert_fails({cmd} [, {error} [, {msg} [, {lnum} [, {context}]]]]) Note that beeping is not considered an error, and some failing commands only beep. Use |assert_beeps()| for those. + Parameters: ~ + • {cmd} (`string`) + • {error} (`any?`) + • {msg} (`any?`) + • {lnum} (`integer?`) + • {context} (`any?`) + + Return: ~ + (`0|1`) + assert_false({actual} [, {msg}]) *assert_false()* 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. + When {msg} is present it is prefixed to that, along with the + location of the assert when run from a script. Also see |assert-return|. A value is false when it is zero. When {actual} is not a number the assert fails. + Parameters: ~ + • {actual} (`any`) + • {msg} (`any?`) + + Return: ~ + (`0|1`) + assert_inrange({lower}, {upper}, {actual} [, {msg}]) *assert_inrange()* This asserts number and |Float| values. When {actual} is lower than {lower} or higher than {upper} an error message is added @@ -254,11 +375,21 @@ assert_inrange({lower}, {upper}, {actual} [, {msg}]) *assert_inrange()* but got {actual}". When {msg} is present it is prefixed to that. + Parameters: ~ + • {lower} (`number`) + • {upper} (`number`) + • {actual} (`number`) + • {msg} (`string?`) + + Return: ~ + (`0|1`) + assert_match({pattern}, {actual} [, {msg}]) *assert_match()* 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. + {actual}". When {msg} is present it is prefixed to that, + along with the location of the assert when run from a script. {pattern} is used as with |expr-=~|: The matching is always done like 'magic' was set and 'cpoptions' is empty, no matter what @@ -269,36 +400,80 @@ assert_match({pattern}, {actual} [, {msg}]) *assert_match()* Use both to match the whole text. Example: >vim - assert_match('^f.*o$', 'foobar') + call assert_match('^f.*o$', 'foobar') < Will result in a string to be added to |v:errors|: test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~ + Parameters: ~ + • {pattern} (`string`) + • {actual} (`string`) + • {msg} (`string?`) + + Return: ~ + (`0|1`) + assert_nobeep({cmd}) *assert_nobeep()* Run {cmd} and add an error message to |v:errors| if it produces a beep or visual bell. Also see |assert_beeps()|. + Parameters: ~ + • {cmd} (`string`) + + Return: ~ + (`0|1`) + assert_notequal({expected}, {actual} [, {msg}]) *assert_notequal()* The opposite of `assert_equal()`: add an error message to |v:errors| when {expected} and {actual} are equal. Also see |assert-return|. + Parameters: ~ + • {expected} (`any`) + • {actual} (`any`) + • {msg} (`any?`) + + Return: ~ + (`0|1`) + assert_notmatch({pattern}, {actual} [, {msg}]) *assert_notmatch()* The opposite of `assert_match()`: add an error message to |v:errors| when {pattern} matches {actual}. Also see |assert-return|. + Parameters: ~ + • {pattern} (`string`) + • {actual} (`string`) + • {msg} (`string?`) + + Return: ~ + (`0|1`) + assert_report({msg}) *assert_report()* Report a test failure directly, using String {msg}. Always returns one. + Parameters: ~ + • {msg} (`string`) + + Return: ~ + (`0|1`) + assert_true({actual} [, {msg}]) *assert_true()* When {actual} is not true an error message is added to |v:errors|, like with |assert_equal()|. Also see |assert-return|. A value is |TRUE| when it is a non-zero number or |v:true|. When {actual} is not a number or |v:true| the assert fails. - When {msg} is given it precedes the default message. + When {msg} is given it is prefixed to the default message, + along with the location of the assert when run from a script. + + Parameters: ~ + • {actual} (`any`) + • {msg} (`string?`) + + Return: ~ + (`0|1`) atan({expr}) *atan()* Return the principal value of the arc tangent of {expr}, in @@ -311,6 +486,12 @@ atan({expr}) *atan()* echo atan(-4.01) < -1.326405 + Parameters: ~ + • {expr} (`number`) + + Return: ~ + (`number`) + atan2({expr1}, {expr2}) *atan2()* Return the arc tangent of {expr1} / {expr2}, measured in radians, as a |Float| in the range [-pi, pi]. @@ -323,6 +504,13 @@ atan2({expr1}, {expr2}) *atan2()* echo atan2(1, -1) < 2.356194 + Parameters: ~ + • {expr1} (`number`) + • {expr2} (`number`) + + Return: ~ + (`number`) + blob2list({blob}) *blob2list()* Return a List containing the number value of each byte in Blob {blob}. Examples: >vim @@ -331,6 +519,12 @@ blob2list({blob}) *blob2list()* < Returns an empty List on error. |list2blob()| does the opposite. + Parameters: ~ + • {blob} (`any`) + + Return: ~ + (`any[]`) + browse({save}, {title}, {initdir}, {default}) *browse()* Put up a file requester. This only works when "has("browse")" returns |TRUE| (only in some GUI versions). @@ -342,6 +536,15 @@ browse({save}, {title}, {initdir}, {default}) *browse()* An empty string is returned when the "Cancel" button is hit, something went wrong, or browsing is not possible. + Parameters: ~ + • {save} (`any`) + • {title} (`string`) + • {initdir} (`string`) + • {default} (`string`) + + Return: ~ + (`0|1`) + browsedir({title}, {initdir}) *browsedir()* Put up a directory requester. This only works when "has("browse")" returns |TRUE| (only in some GUI versions). @@ -354,6 +557,13 @@ browsedir({title}, {initdir}) *browsedir()* When the "Cancel" button is hit, something went wrong, or browsing is not possible, an empty string is returned. + Parameters: ~ + • {title} (`string`) + • {initdir} (`string`) + + Return: ~ + (`0|1`) + bufadd({name}) *bufadd()* Add a buffer to the buffer list with name {name} (must be a String). @@ -368,6 +578,12 @@ bufadd({name}) *bufadd()* call setbufline(bufnr, 1, ['some', 'text']) < Returns 0 on error. + Parameters: ~ + • {name} (`string`) + + Return: ~ + (`integer`) + bufexists({buf}) *bufexists()* The result is a Number, which is |TRUE| if a buffer called {buf} exists. @@ -390,11 +606,23 @@ bufexists({buf}) *bufexists()* Use "bufexists(0)" to test for the existence of an alternate file name. + Parameters: ~ + • {buf} (`any`) + + Return: ~ + (`0|1`) + buflisted({buf}) *buflisted()* The result is a Number, which is |TRUE| if a buffer called {buf} exists and is listed (has the 'buflisted' option set). The {buf} argument is used like with |bufexists()|. + Parameters: ~ + • {buf} (`any`) + + Return: ~ + (`0|1`) + bufload({buf}) *bufload()* Ensure the buffer {buf} is loaded. When the buffer name refers to an existing file then the file is read. Otherwise @@ -405,11 +633,20 @@ bufload({buf}) *bufload()* there will be no dialog, the buffer will be loaded anyway. The {buf} argument is used like with |bufexists()|. + Parameters: ~ + • {buf} (`any`) + bufloaded({buf}) *bufloaded()* The result is a Number, which is |TRUE| if a buffer called {buf} exists and is loaded (shown in a window or hidden). The {buf} argument is used like with |bufexists()|. + Parameters: ~ + • {buf} (`any`) + + Return: ~ + (`0|1`) + bufname([{buf}]) *bufname()* The result is the name of a buffer. Mostly as it is displayed by the `:ls` command, but not using special names such as @@ -441,6 +678,12 @@ bufname([{buf}]) *bufname()* echo bufname("file2") " name of buffer where "file2" matches. < + Parameters: ~ + • {buf} (`integer|string?`) + + Return: ~ + (`string`) + bufnr([{buf} [, {create}]]) *bufnr()* The result is the number of a buffer, as it is displayed by the `:ls` command. For the use of {buf}, see |bufname()| @@ -455,6 +698,13 @@ bufnr([{buf} [, {create}]]) *bufnr()* number necessarily exist, because ":bwipeout" may have removed them. Use bufexists() to test for the existence of a buffer. + Parameters: ~ + • {buf} (`integer|string?`) + • {create} (`any?`) + + Return: ~ + (`integer`) + bufwinid({buf}) *bufwinid()* The result is a Number, which is the |window-ID| of the first window associated with buffer {buf}. For the use of {buf}, @@ -466,6 +716,12 @@ bufwinid({buf}) *bufwinid()* Only deals with the current tab page. See |win_findbuf()| for finding more. + Parameters: ~ + • {buf} (`any`) + + Return: ~ + (`integer`) + bufwinnr({buf}) *bufwinnr()* Like |bufwinid()| but return the window number instead of the |window-ID|. @@ -477,6 +733,12 @@ bufwinnr({buf}) *bufwinnr()* < The number can be used with |CTRL-W_w| and ":wincmd w" |:wincmd|. + Parameters: ~ + • {buf} (`any`) + + Return: ~ + (`integer`) + byte2line({byte}) *byte2line()* Return the line number that contains the character at byte count {byte} in the current buffer. This includes the @@ -487,6 +749,12 @@ byte2line({byte}) *byte2line()* Returns -1 if the {byte} value is invalid. + Parameters: ~ + • {byte} (`any`) + + Return: ~ + (`integer`) + byteidx({expr}, {nr} [, {utf16}]) *byteidx()* Return byte index of the {nr}th character in the String {expr}. Use zero for the first character, it then returns @@ -523,6 +791,14 @@ byteidx({expr}, {nr} [, {utf16}]) *byteidx()* echo byteidx('a😊😊', 3, 1) " returns 5 < + Parameters: ~ + • {expr} (`any`) + • {nr} (`integer`) + • {utf16} (`any?`) + + Return: ~ + (`integer`) + byteidxcomp({expr}, {nr} [, {utf16}]) *byteidxcomp()* Like byteidx(), except that a composing character is counted as a separate character. Example: >vim @@ -534,6 +810,14 @@ byteidxcomp({expr}, {nr} [, {utf16}]) *byteidxcomp()* character is 3 bytes), the second echo results in 1 ('e' is one byte). + Parameters: ~ + • {expr} (`any`) + • {nr} (`integer`) + • {utf16} (`any?`) + + Return: ~ + (`integer`) + call({func}, {arglist} [, {dict}]) *call()* *E699* Call function {func} with the items in |List| {arglist} as arguments. @@ -543,6 +827,14 @@ call({func}, {arglist} [, {dict}]) *call()* *E69 {dict} is for functions with the "dict" attribute. It will be used to set the local variable "self". |Dictionary-function| + Parameters: ~ + • {func} (`any`) + • {arglist} (`any`) + • {dict} (`any?`) + + Return: ~ + (`any`) + ceil({expr}) *ceil()* Return the smallest integral value greater than or equal to {expr} as a |Float| (round up). @@ -557,6 +849,12 @@ ceil({expr}) *ceil()* Returns 0.0 if {expr} is not a |Float| or a |Number|. + Parameters: ~ + • {expr} (`number`) + + Return: ~ + (`number`) + chanclose({id} [, {stream}]) *chanclose()* Close a channel or a specific stream associated with it. For a job, {stream} can be one of "stdin", "stdout", @@ -567,6 +865,13 @@ chanclose({id} [, {stream}]) *chanclose()* For a socket, there is only one stream, and {stream} should be omitted. + Parameters: ~ + • {id} (`integer`) + • {stream} (`string?`) + + Return: ~ + (`0|1`) + changenr() *changenr()* Return the number of the most recent change. This is the same number as what is displayed with |:undolist| and can be used @@ -576,6 +881,9 @@ changenr() *changenr()* one less than the number of the undone change. Returns 0 if the undo list is empty. + Return: ~ + (`integer`) + chansend({id}, {data}) *chansend()* Send data to channel {id}. For a job, it writes it to the stdin of the process. For the stdio channel |channel-stdio|, @@ -594,6 +902,13 @@ chansend({id}, {data}) *chansend()* was created with `"rpc":v:true` then the channel expects RPC messages, use |rpcnotify()| and |rpcrequest()| instead. + Parameters: ~ + • {id} (`number`) + • {data} (`string|string[]`) + + Return: ~ + (`0|1`) + char2nr({string} [, {utf8}]) *char2nr()* Return Number value of the first char in {string}. Examples: >vim @@ -609,6 +924,13 @@ char2nr({string} [, {utf8}]) *char2nr()* Returns 0 if {string} is not a |String|. + Parameters: ~ + • {string} (`string`) + • {utf8} (`any?`) + + Return: ~ + (`0|1`) + charclass({string}) *charclass()* Return the character class of the first character in {string}. The character class is one of: @@ -620,6 +942,12 @@ charclass({string}) *charclass()* The class is used in patterns and word motions. Returns 0 if {string} is not a |String|. + Parameters: ~ + • {string} (`string`) + + Return: ~ + (`0|1|2|3|'other'`) + charcol({expr} [, {winid}]) *charcol()* Same as |col()| but returns the character index of the column position given with {expr} instead of the byte position. @@ -628,6 +956,14 @@ charcol({expr} [, {winid}]) *charcol()* With the cursor on '세' in line 5 with text "여보세요": >vim echo charcol('.') " returns 3 echo col('.') " returns 7 +< + + Parameters: ~ + • {expr} (`string|integer[]`) + • {winid} (`integer?`) + + Return: ~ + (`integer`) charidx({string}, {idx} [, {countcc} [, {utf16}]]) *charidx()* Return the character index of the byte at {idx} in {string}. @@ -663,6 +999,15 @@ charidx({string}, {idx} [, {countcc} [, {utf16}]]) *charidx()* echo charidx('a😊😊', 4, 0, 1) " returns 2 < + Parameters: ~ + • {string} (`string`) + • {idx} (`integer`) + • {countcc} (`boolean?`) + • {utf16} (`boolean?`) + + Return: ~ + (`integer`) + chdir({dir}) *chdir()* Change the current working directory to {dir}. The scope of the directory change depends on the directory of the current @@ -684,6 +1029,13 @@ chdir({dir}) *chdir()* " ... do some work call chdir(save_dir) endif +< + + Parameters: ~ + • {dir} (`string`) + + Return: ~ + (`string`) cindent({lnum}) *cindent()* Get the amount of indent for line {lnum} according the C @@ -693,41 +1045,50 @@ cindent({lnum}) *cindent()* When {lnum} is invalid -1 is returned. See |C-indenting|. + Parameters: ~ + • {lnum} (`integer`) + + Return: ~ + (`integer`) + clearmatches([{win}]) *clearmatches()* 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. + Parameters: ~ + • {win} (`integer?`) + col({expr} [, {winid}]) *col()* 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. + position given with {expr}. + For accepted positions see |getpos()|. + When {expr} is "$", it means the end of the cursor line, so + the result is the number of bytes in the cursor line plus one. 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 -< The first column is 1. Returns 0 if {expr} is invalid or when +< + The first column is 1. Returns 0 if {expr} is invalid or when the window with ID {winid} is not found. For an uppercase mark the column may actually be in another buffer. @@ -736,6 +1097,14 @@ col({expr} [, {winid}]) *col()* line. Also, when using a <Cmd> mapping the cursor isn't moved, this can be used to obtain the column in Insert mode: >vim imap <F2> <Cmd>echo col(".").."\n"<CR> +< + + Parameters: ~ + • {expr} (`string|integer[]`) + • {winid} (`integer?`) + + Return: ~ + (`integer`) complete({startcol}, {matches}) *complete()* *E785* Set the matches for Insert mode completion. @@ -767,6 +1136,10 @@ complete({startcol}, {matches}) *complete()* *E78 < This isn't very useful, but it shows how it works. Note that an empty string is returned to avoid a zero being inserted. + Parameters: ~ + • {startcol} (`integer`) + • {matches} (`any[]`) + complete_add({expr}) *complete_add()* Add {expr} to the list of matches. Only to be used by the function specified with the 'completefunc' option. @@ -776,6 +1149,12 @@ complete_add({expr}) *complete_add()* See |complete-functions| for an explanation of {expr}. It is the same as one item in the list that 'omnifunc' would return. + Parameters: ~ + • {expr} (`any`) + + Return: ~ + (`0|1|2`) + complete_check() *complete_check()* Check for a key typed while looking for completion matches. This is to be used when looking for matches takes some time. @@ -784,6 +1163,9 @@ complete_check() *complete_check()* Only to be used by the function specified with the 'completefunc' option. + Return: ~ + (`0|1`) + complete_info([{what}]) *complete_info()* Returns a |Dictionary| with information about Insert mode completion. See |ins-completion|. @@ -843,6 +1225,13 @@ complete_info([{what}]) *complete_info()* call complete_info(['mode']) " Get only 'mode' and 'pum_visible' call complete_info(['mode', 'pum_visible']) +< + + Parameters: ~ + • {what} (`any[]?`) + + Return: ~ + (`table`) confirm({msg} [, {choices} [, {default} [, {type}]]]) *confirm()* confirm() offers the user a dialog, from which a choice can be @@ -896,6 +1285,15 @@ confirm({msg} [, {choices} [, {default} [, {type}]]]) *confirm()* don't fit, a vertical layout is used anyway. For some systems the horizontal layout is always used. + Parameters: ~ + • {msg} (`string`) + • {choices} (`string?`) + • {default} (`integer?`) + • {type} (`string?`) + + Return: ~ + (`integer`) + copy({expr}) *copy()* Make a copy of {expr}. For Numbers and Strings this isn't different from using {expr} directly. @@ -906,6 +1304,12 @@ copy({expr}) *copy()* A |Dictionary| is copied in a similar way as a |List|. Also see |deepcopy()|. + Parameters: ~ + • {expr} (`any`) + + Return: ~ + (`any`) + cos({expr}) *cos()* Return the cosine of {expr}, measured in radians, as a |Float|. {expr} must evaluate to a |Float| or a |Number|. @@ -916,6 +1320,12 @@ cos({expr}) *cos()* echo cos(-4.01) < -0.646043 + Parameters: ~ + • {expr} (`number`) + + Return: ~ + (`number`) + cosh({expr}) *cosh()* Return the hyperbolic cosine of {expr} as a |Float| in the range [1, inf]. @@ -927,6 +1337,12 @@ cosh({expr}) *cosh()* echo cosh(-0.5) < -1.127626 + Parameters: ~ + • {expr} (`number`) + + Return: ~ + (`number`) + count({comp}, {expr} [, {ic} [, {start}]]) *count()* *E706* Return the number of times an item with value {expr} appears in |String|, |List| or |Dictionary| {comp}. @@ -940,15 +1356,33 @@ count({comp}, {expr} [, {ic} [, {start}]]) *count()* *E70 occurrences of {expr} is returned. Zero is returned when {expr} is an empty string. + Parameters: ~ + • {comp} (`string|table|any[]`) + • {expr} (`any`) + • {ic} (`boolean?`) + • {start} (`integer?`) + + Return: ~ + (`integer`) + ctxget([{index}]) *ctxget()* 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). + Parameters: ~ + • {index} (`integer?`) + + Return: ~ + (`table`) + ctxpop() *ctxpop()* Pops and restores the |context| at the top of the |context-stack|. + Return: ~ + (`any`) + ctxpush([{types}]) *ctxpush()* Pushes the current editor state (|context|) on the |context-stack|. @@ -956,15 +1390,31 @@ ctxpush([{types}]) *ctxpush()* which |context-types| to include in the pushed context. Otherwise, all context types are included. + Parameters: ~ + • {types} (`string[]?`) + + Return: ~ + (`any`) + ctxset({context} [, {index}]) *ctxset()* 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). + Parameters: ~ + • {context} (`table`) + • {index} (`integer?`) + + Return: ~ + (`any`) + ctxsize() *ctxsize()* Returns the size of the |context-stack|. + Return: ~ + (`any`) + cursor({lnum}, {col} [, {off}]) *cursor()* cursor({list}) Positions the cursor at the column (byte count) {col} in the @@ -998,6 +1448,12 @@ cursor({list}) position within a <Tab> or after the last character. Returns 0 when the position could be set, -1 otherwise. + Parameters: ~ + • {list} (`integer[]`) + + Return: ~ + (`any`) + debugbreak({pid}) *debugbreak()* Specifically used to interrupt a program being debugged. It will cause process {pid} to get a SIGTRAP. Behavior for other @@ -1007,6 +1463,12 @@ debugbreak({pid}) *debugbreak()* Returns |TRUE| if successfully interrupted the program. Otherwise returns |FALSE|. + Parameters: ~ + • {pid} (`integer`) + + Return: ~ + (`any`) + deepcopy({expr} [, {noref}]) *deepcopy()* *E698* Make a copy of {expr}. For Numbers and Strings this isn't different from using {expr} directly. @@ -1027,6 +1489,13 @@ deepcopy({expr} [, {noref}]) *deepcopy()* *E69 {noref} set to 1 will fail. Also see |copy()|. + Parameters: ~ + • {expr} (`any`) + • {noref} (`boolean?`) + + Return: ~ + (`any`) + delete({fname} [, {flags}]) *delete()* Without {flags} or with {flags} empty: Deletes the file by the name {fname}. @@ -1046,6 +1515,13 @@ delete({fname} [, {flags}]) *delete()* operation was successful and -1/true when the deletion failed or partly failed. + Parameters: ~ + • {fname} (`string`) + • {flags} (`string?`) + + Return: ~ + (`integer`) + deletebufline({buf}, {first} [, {last}]) *deletebufline()* Delete lines {first} to {last} (inclusive) from buffer {buf}. If {last} is omitted then delete line {first} only. @@ -1060,6 +1536,14 @@ deletebufline({buf}, {first} [, {last}]) *deletebufline()* when using |line()| this refers to the current buffer. Use "$" to refer to the last line in buffer {buf}. + Parameters: ~ + • {buf} (`integer|string`) + • {first} (`integer|string`) + • {last} (`integer|string?`) + + Return: ~ + (`any`) + dictwatcheradd({dict}, {pattern}, {callback}) *dictwatcheradd()* Adds a watcher to a dictionary. A dictionary watcher is identified by three components: @@ -1100,11 +1584,27 @@ dictwatcheradd({dict}, {pattern}, {callback}) *dictwatcheradd()* This function can be used by plugins to implement options with validation and parsing logic. + Parameters: ~ + • {dict} (`table`) + • {pattern} (`string`) + • {callback} (`function`) + + Return: ~ + (`any`) + dictwatcherdel({dict}, {pattern}, {callback}) *dictwatcherdel()* 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. + Parameters: ~ + • {dict} (`any`) + • {pattern} (`string`) + • {callback} (`function`) + + Return: ~ + (`any`) + did_filetype() *did_filetype()* Returns |TRUE| when autocommands are being executed and the FileType event has been triggered at least once. Can be used @@ -1117,6 +1617,9 @@ did_filetype() *did_filetype()* editing another buffer to set 'filetype' and load a syntax file. + Return: ~ + (`any`) + diff_filler({lnum}) *diff_filler()* Returns the number of filler lines above line {lnum}. These are the lines that were inserted at this point in @@ -1126,6 +1629,12 @@ diff_filler({lnum}) *diff_filler()* line, "'m" mark m, etc. Returns 0 if the current window is not in diff mode. + Parameters: ~ + • {lnum} (`integer`) + + Return: ~ + (`any`) + diff_hlID({lnum}, {col}) *diff_hlID()* Returns the highlight ID for diff mode at line {lnum} column {col} (byte index). When the current line does not have a @@ -1137,6 +1646,13 @@ diff_hlID({lnum}, {col}) *diff_hlID()* The highlight ID can be used with |synIDattr()| to obtain syntax information about the highlighting. + Parameters: ~ + • {lnum} (`integer`) + • {col} (`integer`) + + Return: ~ + (`any`) + digraph_get({chars}) *digraph_get()* *E1214* Return the digraph of {chars}. This should be a string with exactly two characters. If {chars} are not just two @@ -1154,6 +1670,12 @@ digraph_get({chars}) *digraph_get()* *E121 echo digraph_get('aa') " Returns 'あ' < + Parameters: ~ + • {chars} (`string`) + + Return: ~ + (`any`) + digraph_getlist([{listall}]) *digraph_getlist()* Return a list of digraphs. If the {listall} argument is given and it is TRUE, return all digraphs, including the default @@ -1169,6 +1691,12 @@ digraph_getlist([{listall}]) *digraph_getlist()* echo digraph_getlist(1) < + Parameters: ~ + • {listall} (`boolean?`) + + Return: ~ + (`any`) + digraph_set({chars}, {digraph}) *digraph_set()* Add digraph {chars} to the list. {chars} must be a string with two characters. {digraph} is a string with one UTF-8 @@ -1186,9 +1714,13 @@ digraph_set({chars}, {digraph}) *digraph_set()* Example: >vim call digraph_set(' ', 'あ') < - Can be used as a |method|: >vim - GetString()->digraph_set('あ') -< + + Parameters: ~ + • {chars} (`string`) + • {digraph} (`string`) + + Return: ~ + (`any`) digraph_setlist({digraphlist}) *digraph_setlist()* Similar to |digraph_set()| but this function can add multiple @@ -1205,9 +1737,11 @@ digraph_setlist({digraphlist}) *digraph_setlist()* < Except that the function returns after the first error, following digraphs will not be added. - Can be used as a |method|: >vim - GetList()->digraph_setlist() -< + Parameters: ~ + • {digraphlist} (`table<integer,string[]>`) + + Return: ~ + (`any`) empty({expr}) *empty()* Return the Number 1 if {expr} is empty, zero otherwise. @@ -1218,6 +1752,12 @@ empty({expr}) *empty()* - |v:false| and |v:null| are empty, |v:true| is not. - A |Blob| is empty when its length is zero. + Parameters: ~ + • {expr} (`any`) + + Return: ~ + (`any`) + environ() *environ()* Return all of environment variables as dictionary. You can check if an environment variable exists like this: >vim @@ -1227,6 +1767,9 @@ environ() *environ()* echo index(keys(environ()), 'HOME', 0, 1) != -1 < + Return: ~ + (`any`) + escape({string}, {chars}) *escape()* Escape the characters in {chars} that occur in {string} with a backslash. Example: >vim @@ -1235,6 +1778,13 @@ escape({string}, {chars}) *escape()* c:\\program\ files\\vim < Also see |shellescape()| and |fnameescape()|. + Parameters: ~ + • {string} (`string`) + • {chars} (`string`) + + Return: ~ + (`any`) + eval({string}) *eval()* Evaluate {string} and return the result. Especially useful to turn the result of |string()| back into the original value. @@ -1242,34 +1792,56 @@ eval({string}) *eval()* of them. Also works for |Funcref|s that refer to existing functions. + Parameters: ~ + • {string} (`string`) + + Return: ~ + (`any`) + eventhandler() *eventhandler()* Returns 1 when inside an event handler. That is that Vim got interrupted while waiting for the user to type a character, e.g., when dropping a file on Vim. This means interactive commands cannot be used. Otherwise zero is returned. + Return: ~ + (`any`) + executable({expr}) *executable()* This function checks if an executable with the name {expr} exists. {expr} must be the name of the program without any arguments. + executable() uses the value of $PATH and/or the normal - searchpath for programs. *PATHEXT* + searchpath for programs. + *PATHEXT* On MS-Windows the ".exe", ".bat", etc. can optionally be included. Then the extensions in $PATHEXT are tried. Thus if "foo.exe" does not exist, "foo.exe.bat" can be found. If - $PATHEXT is not set then ".exe;.com;.bat;.cmd" is used. A dot + $PATHEXT is not set then ".com;.exe;.bat;.cmd" is used. A dot by itself can be used in $PATHEXT to try using the name without an extension. When 'shell' looks like a Unix shell, then the name is also tried without adding an extension. On MS-Windows it only checks if the file exists and is not a directory, not if it's really executable. - On Windows an executable in the same directory as Vim is - always found (it is added to $PATH at |startup|). + On MS-Windows an executable in the same directory as the Vim + executable is always found (it's added to $PATH at |startup|). + *NoDefaultCurrentDirectoryInExePath* + On MS-Windows an executable in Vim's current working directory + is also normally found, but this can be disabled by setting + the $NoDefaultCurrentDirectoryInExePath environment variable. + The result is a Number: 1 exists 0 does not exist |exepath()| can be used to get the full path of an executable. + Parameters: ~ + • {expr} (`string`) + + Return: ~ + (`0|1`) + execute({command} [, {silent}]) *execute()* Execute {command} and capture its output. If {command} is a |String|, returns {command} output. @@ -1298,12 +1870,25 @@ execute({command} [, {silent}]) *execute()* To execute a command in another window than the current one use `win_execute()`. + Parameters: ~ + • {command} (`string|string[]`) + • {silent} (`''|'silent'|'silent!'?`) + + Return: ~ + (`string`) + exepath({expr}) *exepath()* Returns the full path of {expr} if it is an executable and given as a (partial or full) path or is found in $PATH. Returns empty string otherwise. If {expr} starts with "./" the |current-directory| is used. + Parameters: ~ + • {expr} (`string`) + + Return: ~ + (`string`) + exists({expr}) *exists()* The result is a Number, which is |TRUE| if {expr} is defined, zero otherwise. @@ -1393,6 +1978,12 @@ exists({expr}) *exists()* < This doesn't check for existence of the "bufcount" variable, but gets the value of "bufcount", and checks if that exists. + Parameters: ~ + • {expr} (`string`) + + Return: ~ + (`0|1`) + exp({expr}) *exp()* Return the exponential of {expr} as a |Float| in the range [0, inf]. @@ -1404,6 +1995,12 @@ exp({expr}) *exp()* echo exp(-1) < 0.367879 + Parameters: ~ + • {expr} (`number`) + + Return: ~ + (`any`) + expand({string} [, {nosuf} [, {list}]]) *expand()* Expand wildcards and the following special keywords in {string}. 'wildignorecase' applies. @@ -1495,6 +2092,14 @@ expand({string} [, {nosuf} [, {list}]]) *expand()* 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, @@ -1519,6 +2124,13 @@ expandcmd({string} [, {options}]) *expandcmd()* 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|. @@ -1555,11 +2167,27 @@ extend({expr1}, {expr2} [, {expr3}]) *extend()* 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 List or Dictionary is created and returned. {expr1} remains unchanged. + Parameters: ~ + • {expr1} (`table`) + • {expr2} (`table`) + • {expr3} (`table?`) + + Return: ~ + (`any`) + feedkeys({string} [, {mode}]) *feedkeys()* Characters in {string} are queued for processing as if they come from a mapping or were typed by the user. @@ -1606,6 +2234,29 @@ feedkeys({string} [, {mode}]) *feedkeys()* Return value is always 0. + Parameters: ~ + • {string} (`string`) + • {mode} (`string?`) + + Return: ~ + (`any`) + +filecopy({from}, {to}) *filecopy()* + Copy the file pointed to by the name {from} to {to}. The + result is a Number, which is |TRUE| if the file was copied + successfully, and |FALSE| when it failed. + If a file with name {to} already exists, it will fail. + Note that it does not handle directories (yet). + + This function is not available in the |sandbox|. + + Parameters: ~ + • {from} (`string`) + • {to} (`string`) + + Return: ~ + (`0|1`) + filereadable({file}) *filereadable()* The result is a Number, which is |TRUE| when a file with the name {file} exists, and can be read. If {file} doesn't exist, @@ -1623,12 +2274,24 @@ filereadable({file}) *filereadable()* 1 < + Parameters: ~ + • {file} (`string`) + + Return: ~ + (`0|1`) + filewritable({file}) *filewritable()* The result is a Number, which is 1 when a file with the name {file} exists, and can be written. If {file} doesn't exist, or is not writable, the result is 0. If {file} is a directory, and we can write to it, the result is 2. + Parameters: ~ + • {file} (`string`) + + Return: ~ + (`0|1`) + filter({expr1}, {expr2}) *filter()* {expr1} must be a |List|, |String|, |Blob| or |Dictionary|. For each item in {expr1} evaluate {expr2} and when the result @@ -1682,6 +2345,13 @@ filter({expr1}, {expr2}) *filter()* When {expr2} is a Funcref errors inside a function are ignored, unless it was defined with the "abort" flag. + Parameters: ~ + • {expr1} (`string|table`) + • {expr2} (`string|function`) + + Return: ~ + (`any`) + finddir({name} [, {path} [, {count}]]) *finddir()* Find directory {name} in {path}. Supports both downwards and upwards recursive directory searches. See |file-searching| @@ -1700,6 +2370,14 @@ finddir({name} [, {path} [, {count}]]) *finddir()* This is quite similar to the ex-command `:find`. + Parameters: ~ + • {name} (`string`) + • {path} (`string?`) + • {count} (`integer?`) + + Return: ~ + (`any`) + findfile({name} [, {path} [, {count}]]) *findfile()* Just like |finddir()|, but find a file instead of a directory. Uses 'suffixesadd'. @@ -1708,6 +2386,14 @@ findfile({name} [, {path} [, {count}]]) *findfile()* < Searches from the directory of the current file upwards until it finds the file "tags.vim". + Parameters: ~ + • {name} (`string`) + • {path} (`string?`) + • {count} (`any?`) + + Return: ~ + (`any`) + flatten({list} [, {maxdepth}]) *flatten()* Flatten {list} up to {maxdepth} levels. Without {maxdepth} the result is a |List| without nesting, as if {maxdepth} is @@ -1727,9 +2413,23 @@ flatten({list} [, {maxdepth}]) *flatten()* echo flatten([1, [2, [3, 4]], 5], 1) < [1, 2, [3, 4], 5] + Parameters: ~ + • {list} (`any[]`) + • {maxdepth} (`integer?`) + + Return: ~ + (`any[]|0`) + flattennew({list} [, {maxdepth}]) *flattennew()* Like |flatten()| but first make a copy of {list}. + Parameters: ~ + • {list} (`any[]`) + • {maxdepth} (`integer?`) + + Return: ~ + (`any[]|0`) + float2nr({expr}) *float2nr()* Convert {expr} to a Number by omitting the part after the decimal point. @@ -1752,6 +2452,12 @@ float2nr({expr}) *float2nr()* echo float2nr(1.0e-100) < 0 + Parameters: ~ + • {expr} (`number`) + + Return: ~ + (`any`) + floor({expr}) *floor()* Return the largest integral value less than or equal to {expr} as a |Float| (round down). @@ -1765,6 +2471,12 @@ floor({expr}) *floor()* echo floor(4.0) < 4.0 + Parameters: ~ + • {expr} (`number`) + + Return: ~ + (`any`) + fmod({expr1}, {expr2}) *fmod()* Return the remainder of {expr1} / {expr2}, even if the division is not representable. Returns {expr1} - i * {expr2} @@ -1781,6 +2493,13 @@ fmod({expr1}, {expr2}) *fmod()* echo fmod(-12.33, 1.22) < -0.13 + Parameters: ~ + • {expr1} (`number`) + • {expr2} (`number`) + + Return: ~ + (`any`) + fnameescape({string}) *fnameescape()* Escape {string} for use as file name command argument. All characters that have a special meaning, such as `'%'` and `'|'` @@ -1798,6 +2517,12 @@ fnameescape({string}) *fnameescape()* edit \+some\ str\%nge\|name < + Parameters: ~ + • {string} (`string`) + + Return: ~ + (`string`) + fnamemodify({fname}, {mods}) *fnamemodify()* Modify file name {fname} according to {mods}. {mods} is a string of characters like it is used for file names on the @@ -1815,6 +2540,13 @@ fnamemodify({fname}, {mods}) *fnamemodify()* Note: Environment variables don't work in {fname}, use |expand()| first then. + Parameters: ~ + • {fname} (`string`) + • {mods} (`string`) + + Return: ~ + (`string`) + foldclosed({lnum}) *foldclosed()* The result is a Number. If the line {lnum} is in a closed fold, the result is the number of the first line in that fold. @@ -1822,6 +2554,12 @@ foldclosed({lnum}) *foldclosed()* {lnum} is used like with |getline()|. Thus "." is the current line, "'m" mark m, etc. + Parameters: ~ + • {lnum} (`integer`) + + Return: ~ + (`integer`) + foldclosedend({lnum}) *foldclosedend()* The result is a Number. If the line {lnum} is in a closed fold, the result is the number of the last line in that fold. @@ -1829,6 +2567,12 @@ foldclosedend({lnum}) *foldclosedend()* {lnum} is used like with |getline()|. Thus "." is the current line, "'m" mark m, etc. + Parameters: ~ + • {lnum} (`integer`) + + Return: ~ + (`integer`) + foldlevel({lnum}) *foldlevel()* The result is a Number, which is the foldlevel of line {lnum} in the current buffer. For nested folds the deepest level is @@ -1841,6 +2585,12 @@ foldlevel({lnum}) *foldlevel()* {lnum} is used like with |getline()|. Thus "." is the current line, "'m" mark m, etc. + Parameters: ~ + • {lnum} (`integer`) + + Return: ~ + (`integer`) + foldtext() *foldtext()* Returns a String, to be displayed for a closed fold. This is the default function used for the 'foldtext' option and should @@ -1858,6 +2608,9 @@ foldtext() *foldtext()* setting. Returns an empty string when there is no fold. + Return: ~ + (`string`) + foldtextresult({lnum}) *foldtextresult()* Returns the text that is displayed for the closed fold at line {lnum}. Evaluates 'foldtext' in the appropriate context. @@ -1867,6 +2620,12 @@ foldtextresult({lnum}) *foldtextresult()* line, "'m" mark m, etc. Useful when exporting folded text, e.g., to HTML. + Parameters: ~ + • {lnum} (`integer`) + + Return: ~ + (`string`) + foreach({expr1}, {expr2}) *foreach()* {expr1} must be a |List|, |String|, |Blob| or |Dictionary|. For each item in {expr1} execute {expr2}. {expr1} is not @@ -1902,6 +2661,13 @@ foreach({expr1}, {expr2}) *foreach()* When {expr2} is a Funcref errors inside a function are ignored, unless it was defined with the "abort" flag. + Parameters: ~ + • {expr1} (`string|table`) + • {expr2} (`string|function`) + + Return: ~ + (`any`) + fullcommand({name}) *fullcommand()* Get the full command name from a short abbreviated command name; see |20.2| for details on command abbreviations. @@ -1914,6 +2680,12 @@ fullcommand({name}) *fullcommand()* For example `fullcommand('s')`, `fullcommand('sub')`, `fullcommand(':%substitute')` all return "substitute". + Parameters: ~ + • {name} (`string`) + + Return: ~ + (`string`) + funcref({name} [, {arglist}] [, {dict}]) *funcref()* Just like |function()|, but the returned Funcref will lookup the function by reference, not by name. This matters when the @@ -1926,6 +2698,14 @@ funcref({name} [, {arglist}] [, {dict}]) *funcref()* instead). {name} cannot be a builtin function. Returns 0 on error. + Parameters: ~ + • {name} (`string`) + • {arglist} (`any?`) + • {dict} (`any?`) + + Return: ~ + (`any`) + function({name} [, {arglist}] [, {dict}]) *function()* *partial* *E700* *E923* Return a |Funcref| variable that refers to function {name}. {name} can be the name of a user defined function or an @@ -2008,6 +2788,14 @@ function({name} [, {arglist}] [, {dict}]) *function()* *partial* *E700* < Returns 0 on error. + Parameters: ~ + • {name} (`string`) + • {arglist} (`any?`) + • {dict} (`any?`) + + Return: ~ + (`any`) + garbagecollect([{atexit}]) *garbagecollect()* Cleanup unused |Lists| and |Dictionaries| that have circular references. @@ -2028,17 +2816,39 @@ garbagecollect([{atexit}]) *garbagecollect()* it's safe to perform. This is when waiting for the user to type a character. -get({list}, {idx} [, {default}]) *get()* + 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. -get({blob}, {idx} [, {default}]) + 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. -get({dict}, {key} [, {default}]) + 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 @@ -2046,15 +2856,43 @@ get({dict}, {key} [, {default}]) < This gets the value of g:var_name if it exists, and uses "default" when it does not exist. -get({func}, {what}) - Get item {what} from Funcref {func}. Possible values for + 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 + "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. @@ -2124,6 +2962,12 @@ getbufinfo([{dict}]) getbufvar({bufnr}, '&option_name') < + Parameters: ~ + • {dict} (`vim.fn.getbufinfo.dict?`) + + Return: ~ + (`vim.fn.getbufinfo.ret.item[]`) + getbufline({buf}, {lnum} [, {end}]) *getbufline()* Return a |List| with the lines starting from {lnum} to {end} (inclusive) in the buffer {buf}. If {end} is omitted, a @@ -2148,11 +2992,27 @@ getbufline({buf}, {lnum} [, {end}]) *getbufline()* Example: >vim let lines = getbufline(bufnr("myfile"), 1, "$") +< + + Parameters: ~ + • {buf} (`integer|string`) + • {lnum} (`integer`) + • {end_} (`integer?`) + + Return: ~ + (`any`) 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:" @@ -2174,12 +3034,23 @@ getbufvar({buf}, {varname} [, {def}]) *getbufvar()* 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 @@ -2196,6 +3067,12 @@ getchangelist([{buf}]) *getchangelist()* 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}]) *getchar()* Get a single character from the user or input stream. If {expr} is omitted, wait until a character is available. @@ -2261,6 +3138,12 @@ getchar([{expr}]) *getchar()* endfunction < + Parameters: ~ + • {expr} (`0|1?`) + + Return: ~ + (`integer`) + getcharmod() *getcharmod()* The result is a Number which is the state of the modifiers for the last obtained character with getchar() or in another way. @@ -2277,6 +3160,9 @@ getcharmod() *getcharmod()* character itself are obtained. Thus Shift-a results in "A" without a modifier. Returns 0 if no modifiers are used. + Return: ~ + (`integer`) + getcharpos({expr}) *getcharpos()* Get the position for String {expr}. Same as |getpos()| but the column number in the returned List is a character index @@ -2291,6 +3177,12 @@ getcharpos({expr}) *getcharpos()* getpos('.') returns [0, 5, 7, 0] < + Parameters: ~ + • {expr} (`string`) + + Return: ~ + (`integer[]`) + getcharsearch() *getcharsearch()* Return the current character search information as a {dict} with the following entries: @@ -2311,6 +3203,9 @@ getcharsearch() *getcharsearch()* nnoremap <expr> , getcharsearch().forward ? ',' : ';' < Also see |setcharsearch()|. + Return: ~ + (`table`) + getcharstr([{expr}]) *getcharstr()* Get a single character from the user or input stream as a string. @@ -2323,34 +3218,60 @@ getcharstr([{expr}]) *getcharstr()* Otherwise this works like |getchar()|, except that a number result is converted to a string. + Parameters: ~ + • {expr} (`0|1?`) + + Return: ~ + (`string`) + getcmdcompltype() *getcmdcompltype()* Return the type of the current command-line completion. Only works when the command line is being edited, thus requires use of |c_CTRL-\_e| or |c_CTRL-R_=|. See |:command-completion| for the return string. - Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()| and - |setcmdline()|. + Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|, + |getcmdprompt()| and |setcmdline()|. Returns an empty string when completion is not defined. + Return: ~ + (`string`) + getcmdline() *getcmdline()* - Return the current command-line. Only works when the command - line is being edited, thus requires use of |c_CTRL-\_e| or - |c_CTRL-R_=|. + Return the current command-line input. Only works when the + command line is being edited, thus requires use of + |c_CTRL-\_e| or |c_CTRL-R_=|. Example: >vim cmap <F7> <C-\>eescape(getcmdline(), ' \')<CR> -< Also see |getcmdtype()|, |getcmdpos()|, |setcmdpos()| and - |setcmdline()|. +< Also see |getcmdtype()|, |getcmdpos()|, |setcmdpos()|, + |getcmdprompt()| and |setcmdline()|. Returns an empty string when entering a password or using |inputsecret()|. + Return: ~ + (`string`) + getcmdpos() *getcmdpos()* Return the position of the cursor in the command line as a byte count. The first column is 1. Only works when editing the command line, thus requires use of |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping. Returns 0 otherwise. - Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()| and - |setcmdline()|. + Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|, + |getcmdprompt()| and |setcmdline()|. + + Return: ~ + (`integer`) + +getcmdprompt() *getcmdprompt()* + Return the current command-line prompt when using functions + like |input()| or |confirm()|. + Only works when the command line is being edited, thus + requires use of |c_CTRL-\_e| or |c_CTRL-R_=|. + Also see |getcmdtype()|, |getcmdline()|, |getcmdpos()|, + |setcmdpos()| and |setcmdline()|. + + Return: ~ + (`string`) getcmdscreenpos() *getcmdscreenpos()* Return the screen position of the cursor in the command line @@ -2362,6 +3283,9 @@ getcmdscreenpos() *getcmdscreenpos()* Also see |getcmdpos()|, |setcmdpos()|, |getcmdline()| and |setcmdline()|. + Return: ~ + (`any`) + getcmdtype() *getcmdtype()* Return the current command-line type. Possible return values are: @@ -2377,11 +3301,17 @@ getcmdtype() *getcmdtype()* Returns an empty string otherwise. Also see |getcmdpos()|, |setcmdpos()| and |getcmdline()|. + Return: ~ + (`':'|'>'|'/'|'?'|'@'|'-'|'='`) + getcmdwintype() *getcmdwintype()* Return the current |command-line-window| type. Possible return values are the same as |getcmdtype()|. Returns an empty string when not in the command-line window. + Return: ~ + (`':'|'>'|'/'|'?'|'@'|'-'|'='`) + getcompletion({pat}, {type} [, {filtered}]) *getcompletion()* Return a list of command-line completion matches. The String {type} argument specifies what for. The following completion @@ -2399,6 +3329,7 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()* customlist,{func} custom completion, defined via {func} diff_buffer |:diffget| and |:diffput| completion dir directory names + dir_in_path directory names in |'cdpath'| environment environment variable names event autocommand events expression Vim expression @@ -2451,6 +3382,14 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()* 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: @@ -2476,6 +3415,12 @@ getcurpos([{winid}]) *getcurpos()* < Note that this only works within the window. See |winrestview()| for restoring more state. + Parameters: ~ + • {winid} (`integer?`) + + Return: ~ + (`any`) + getcursorcharpos([{winid}]) *getcursorcharpos()* Same as |getcurpos()| but the column number in the returned List is a character index instead of a byte index. @@ -2486,6 +3431,12 @@ getcursorcharpos([{winid}]) *getcursorcharpos()* 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 @@ -2502,6 +3453,13 @@ getcwd([{winnr} [, {tabnr}]]) *getcwd()* directory is returned. Throw error if the arguments are invalid. |E5000| |E5001| |E5002| + Parameters: ~ + • {winnr} (`integer?`) + • {tabnr} (`integer?`) + + Return: ~ + (`string`) + getenv({name}) *getenv()* Return the value of environment variable {name}. The {name} argument is a string, without a leading '$'. Example: >vim @@ -2511,6 +3469,12 @@ getenv({name}) *getenv()* is different from a variable set to an empty string. See also |expr-env|. + Parameters: ~ + • {name} (`string`) + + Return: ~ + (`string`) + getfontname([{name}]) *getfontname()* Without an argument returns the name of the normal font being used. Like what is used for the Normal highlight group @@ -2523,6 +3487,12 @@ getfontname([{name}]) *getfontname()* gvimrc file. Use the |GUIEnter| autocommand to use this function just after the GUI has started. + Parameters: ~ + • {name} (`string?`) + + Return: ~ + (`string`) + getfperm({fname}) *getfperm()* The result is a String, which is the read, write, and execute permissions of the given file {fname}. @@ -2540,6 +3510,12 @@ getfperm({fname}) *getfperm()* For setting permissions use |setfperm()|. + Parameters: ~ + • {fname} (`string`) + + Return: ~ + (`string`) + getfsize({fname}) *getfsize()* The result is a Number, which is the size in bytes of the given file {fname}. @@ -2548,6 +3524,12 @@ getfsize({fname}) *getfsize()* If the size of {fname} is too big to fit in a Number then -2 is returned. + Parameters: ~ + • {fname} (`string`) + + Return: ~ + (`integer`) + getftime({fname}) *getftime()* The result is a Number, which is the last modification time of the given file {fname}. The value is measured as seconds @@ -2555,6 +3537,12 @@ getftime({fname}) *getftime()* |localtime()| and |strftime()|. If the file {fname} can't be found -1 is returned. + Parameters: ~ + • {fname} (`string`) + + Return: ~ + (`integer`) + getftype({fname}) *getftype()* The result is a String, which is a description of the kind of file of the given file {fname}. @@ -2575,6 +3563,12 @@ getftype({fname}) *getftype()* systems that support it. On some systems only "dir" and "file" are returned. + Parameters: ~ + • {fname} (`string`) + + Return: ~ + (`'file'|'dir'|'link'|'bdev'|'cdev'|'socket'|'fifo'|'other'`) + getjumplist([{winnr} [, {tabnr}]]) *getjumplist()* Returns the |jumplist| for the specified window. @@ -2595,6 +3589,13 @@ getjumplist([{winnr} [, {tabnr}]]) *getjumplist()* filename filename if available lnum line number + Parameters: ~ + • {winnr} (`integer?`) + • {tabnr} (`integer?`) + + Return: ~ + (`vim.fn.getjumplist.ret`) + getline({lnum} [, {end}]) *getline()* Without {end} the result is a String, which is line {lnum} from the current buffer. Example: >vim @@ -2620,6 +3621,13 @@ getline({lnum} [, {end}]) *getline()* < To get lines from another buffer see |getbufline()| and |getbufoneline()| + Parameters: ~ + • {lnum} (`integer|string`) + • {end_} (`nil|false?`) + + Return: ~ + (`string`) + getloclist({nr} [, {what}]) *getloclist()* Returns a |List| with all the entries in the location list for window {nr}. {nr} can be the window number or the |window-ID|. @@ -2652,6 +3660,13 @@ getloclist({nr} [, {what}]) *getloclist()* echo getloclist(5, {'filewinid': 0}) < + Parameters: ~ + • {nr} (`integer`) + • {what} (`table?`) + + Return: ~ + (`any`) + getmarklist([{buf}]) *getmarklist()* Without the {buf} argument returns a |List| with information about all the global marks. |mark| @@ -2671,6 +3686,12 @@ getmarklist([{buf}]) *getmarklist()* Refer to |getpos()| for getting information about a specific mark. + Parameters: ~ + • {buf} (`integer??`) + + Return: ~ + (`vim.fn.getmarklist.ret.item[]`) + getmatches([{win}]) *getmatches()* Returns a |List| with all matches previously defined for the current window by |matchadd()| and the |:match| commands. @@ -2703,6 +3724,12 @@ getmatches([{win}]) *getmatches()* unlet m < + Parameters: ~ + • {win} (`integer?`) + + Return: ~ + (`any`) + getmousepos() *getmousepos()* Returns a |Dictionary| with the last known position of the mouse. This can be used in a mapping for a mouse click. The @@ -2734,14 +3761,45 @@ getmousepos() *getmousepos()* When using |getchar()| the Vim variables |v:mouse_lnum|, |v:mouse_col| and |v:mouse_winid| also provide these values. + Return: ~ + (`vim.fn.getmousepos.ret`) + getpid() *getpid()* Return a Number which is the process ID of the Vim process. This is a unique number, until Vim exits. + Return: ~ + (`integer`) + getpos({expr}) *getpos()* - Get the position for String {expr}. For possible values of - {expr} see |line()|. For getting the cursor position see - |getcurpos()|. + Get the position for String {expr}. + The accepted values for {expr} are: + . The cursor position. + $ The last line in the current buffer. + 'x Position of mark x (if the mark is not set, 0 is + returned for all values). + w0 First line visible in current window (one if the + display isn't updated, e.g. in silent Ex mode). + w$ Last line visible in current window (this is one + less than "w0" if no lines are visible). + v When not in Visual mode, returns the cursor + position. In Visual mode, returns the other end + of the Visual area. A good way to think about + this is that in Visual mode "v" and "." complement + each other. While "." refers to the cursor + position, "v" refers to where |v_o| would move the + cursor. As a result, you can use "v" and "." + together to work on all of a selection in + characterwise Visual mode. If the cursor is at + the end of a characterwise Visual area, "v" refers + to the start of the same Visual area. And if the + cursor is at the start of a characterwise Visual + area, "v" refers to the end of the same Visual + area. "v" differs from |'<| and |'>| in that it's + updated right away. + Note that a mark in another file can be used. The line number + then applies to another buffer. + The result is a |List| with four numbers: [bufnum, lnum, col, off] "bufnum" is zero, unless a mark like '0 or 'A is used, then it @@ -2752,20 +3810,31 @@ getpos({expr}) *getpos()* it is the offset in screen columns from the start of the character. E.g., a position within a <Tab> or after the last character. - Note that for '< and '> Visual mode matters: when it is "V" - (visual line mode) the column of '< is zero and the column of - '> is a large number equal to |v:maxcol|. + + For getting the cursor position see |getcurpos()|. The column number in the returned List is the byte position within the line. To get the character position in the line, use |getcharpos()|. + + Note that for '< and '> Visual mode matters: when it is "V" + (visual line mode) the column of '< is zero and the column of + '> is a large number equal to |v:maxcol|. A very large column number equal to |v:maxcol| can be returned, in which case it means "after the end of the line". If {expr} is invalid, returns a list with all zeros. + This can be used to save and restore the position of a mark: >vim let save_a_mark = getpos("'a") " ... call setpos("'a", save_a_mark) -< Also see |getcharpos()|, |getcurpos()| and |setpos()|. +< + Also see |getcharpos()|, |getcurpos()| and |setpos()|. + + Parameters: ~ + • {expr} (`string`) + + Return: ~ + (`integer[]`) getqflist([{what}]) *getqflist()* Returns a |List| with all the current quickfix errors. Each @@ -2871,6 +3940,12 @@ getqflist([{what}]) *getqflist()* echo getqflist({'lines' : ["F1:10:L10"]}) < + Parameters: ~ + • {what} (`table?`) + + Return: ~ + (`any`) + getreg([{regname} [, 1 [, {list}]]]) *getreg()* The result is a String, which is the contents of register {regname}. Example: >vim @@ -2894,6 +3969,13 @@ getreg([{regname} [, 1 [, {list}]]]) *getreg()* If {regname} is not specified, |v:register| is used. + Parameters: ~ + • {regname} (`string?`) + • {list} (`nil|false?`) + + Return: ~ + (`string`) + getreginfo([{regname}]) *getreginfo()* Returns detailed information about register {regname} as a Dictionary with the following entries: @@ -2918,6 +4000,12 @@ getreginfo([{regname}]) *getreginfo()* If {regname} is not specified, |v:register| is used. The returned Dictionary can be passed to |setreg()|. + Parameters: ~ + • {regname} (`string?`) + + Return: ~ + (`table`) + getregion({pos1}, {pos2} [, {opts}]) *getregion()* Returns the list of strings from {pos1} to {pos2} from a buffer. @@ -2930,14 +4018,14 @@ getregion({pos1}, {pos2} [, {opts}]) *getregion()* The optional argument {opts} is a Dict and supports the following items: - type Specify the region's selection type - (default: "v"): - "v" for |charwise| mode - "V" for |linewise| mode - "<CTRL-V>" for |blockwise-visual| mode + type Specify the region's selection type. + See |getregtype()| for possible values, + except that the width can be omitted + and an empty string cannot be used. + (default: "v") exclusive If |TRUE|, use exclusive selection - for the end position + for the end position. (default: follow 'selection') You can get the last selection type by |visualmode()|. @@ -2963,12 +4051,20 @@ getregion({pos1}, {pos2} [, {opts}]) *getregion()* difference if the buffer is displayed in a window with different 'virtualedit' or 'list' values. - Examples: > - :xnoremap <CR> + Examples: >vim + xnoremap <CR> \ <Cmd>echom getregion( \ getpos('v'), getpos('.'), #{ type: mode() })<CR> < + Parameters: ~ + • {pos1} (`table`) + • {pos2} (`table`) + • {opts} (`table?`) + + Return: ~ + (`string[]`) + getregionpos({pos1}, {pos2} [, {opts}]) *getregionpos()* Same as |getregion()|, but returns a list of positions describing the buffer text segments bound by {pos1} and @@ -3001,6 +4097,14 @@ getregionpos({pos1}, {pos2} [, {opts}]) *getregionpos()* value of 0 is used for both positions. (default: |FALSE|) + Parameters: ~ + • {pos1} (`table`) + • {pos2} (`table`) + • {opts} (`table?`) + + Return: ~ + (`integer[][][]`) + getregtype([{regname}]) *getregtype()* The result is a String, which is type of register {regname}. The value will be one of: @@ -3012,6 +4116,12 @@ getregtype([{regname}]) *getregtype()* The {regname} argument is a string. If {regname} is not specified, |v:register| is used. + Parameters: ~ + • {regname} (`string?`) + + Return: ~ + (`string`) + getscriptinfo([{opts}]) *getscriptinfo()* Returns a |List| with information about all the sourced Vim scripts in the order they were sourced, like what @@ -3049,6 +4159,12 @@ getscriptinfo([{opts}]) *getscriptinfo()* echo getscriptinfo({'sid': 15})[0].variables < + Parameters: ~ + • {opts} (`table?`) + + Return: ~ + (`vim.fn.getscriptinfo.ret[]`) + gettabinfo([{tabnr}]) *gettabinfo()* If {tabnr} is not specified, then information about all the tab pages is returned as a |List|. Each List item is a @@ -3062,6 +4178,12 @@ gettabinfo([{tabnr}]) *gettabinfo()* tabpage-local variables windows List of |window-ID|s in the tab page. + Parameters: ~ + • {tabnr} (`integer?`) + + Return: ~ + (`any`) + gettabvar({tabnr}, {varname} [, {def}]) *gettabvar()* Get the value of a tab-local variable {varname} in tab page {tabnr}. |t:var| @@ -3072,6 +4194,14 @@ gettabvar({tabnr}, {varname} [, {def}]) *gettabvar()* When the tab or variable doesn't exist {def} or an empty string is returned, there is no error message. + Parameters: ~ + • {tabnr} (`integer`) + • {varname} (`string`) + • {def} (`any?`) + + Return: ~ + (`any`) + gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()* Get the value of window-local variable {varname} in window {winnr} in tab page {tabnr}. @@ -3099,6 +4229,15 @@ gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()* gettabwinvar({tabnr}, {winnr}, '&') < + Parameters: ~ + • {tabnr} (`integer`) + • {winnr} (`integer`) + • {varname} (`string`) + • {def} (`any?`) + + Return: ~ + (`any`) + gettagstack([{winnr}]) *gettagstack()* The result is a Dict, which is the tag stack of window {winnr}. {winnr} can be the window number or the |window-ID|. @@ -3127,6 +4266,12 @@ gettagstack([{winnr}]) *gettagstack()* See |tagstack| for more information about the tag stack. + Parameters: ~ + • {winnr} (`integer?`) + + Return: ~ + (`any`) + gettext({text}) *gettext()* Translate String {text} if possible. This is mainly for use in the distributed Vim scripts. When @@ -3138,6 +4283,12 @@ gettext({text}) *gettext()* xgettext does not understand escaping in single quoted strings. + Parameters: ~ + • {text} (`string`) + + Return: ~ + (`any`) + getwininfo([{winid}]) *getwininfo()* Returns information about windows as a |List| with Dictionaries. @@ -3172,6 +4323,12 @@ getwininfo([{winid}]) *getwininfo()* winrow topmost screen line of the window; "row" from |win_screenpos()| + Parameters: ~ + • {winid} (`integer?`) + + Return: ~ + (`vim.fn.getwininfo.ret.item[]`) + getwinpos([{timeout}]) *getwinpos()* The result is a |List| with two numbers, the result of |getwinposx()| and |getwinposy()| combined: @@ -3193,24 +4350,44 @@ getwinpos([{timeout}]) *getwinpos()* endwhile < + Parameters: ~ + • {timeout} (`integer?`) + + Return: ~ + (`any`) + getwinposx() *getwinposx()* The result is a Number, which is the X coordinate in pixels of the left hand side of the GUI Vim window. The result will be -1 if the information is not available. The value can be used with `:winpos`. + Return: ~ + (`integer`) + getwinposy() *getwinposy()* The result is a Number, which is the Y coordinate in pixels of the top of the GUI Vim window. The result will be -1 if the information is not available. The value can be used with `:winpos`. + Return: ~ + (`integer`) + getwinvar({winnr}, {varname} [, {def}]) *getwinvar()* Like |gettabwinvar()| for the current tabpage. Examples: >vim let list_is_on = getwinvar(2, '&list') echo "myvar = " .. getwinvar(1, 'myvar') + Parameters: ~ + • {winnr} (`integer`) + • {varname} (`string`) + • {def} (`any?`) + + Return: ~ + (`any`) + glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()* Expand the file wildcards in {expr}. See |wildcards| for the use of special characters. @@ -3247,6 +4424,15 @@ glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()* See |expand()| for expanding special Vim variables. See |system()| for getting the raw output of an external command. + Parameters: ~ + • {expr} (`string`) + • {nosuf} (`boolean?`) + • {list} (`boolean?`) + • {alllinks} (`boolean?`) + + Return: ~ + (`any`) + glob2regpat({string}) *glob2regpat()* Convert a file pattern, as used by glob(), into a search pattern. The result can be used to match with a string that @@ -3263,6 +4449,12 @@ glob2regpat({string}) *glob2regpat()* Note that the result depends on the system. On MS-Windows a backslash usually means a path separator. + Parameters: ~ + • {string} (`string`) + + Return: ~ + (`any`) + globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]]) *globpath()* Perform glob() for String {expr} on all directories in {path} and concatenate the results. Example: >vim @@ -3298,6 +4490,16 @@ globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]]) *globpath()* < Upwards search and limiting the depth of "**" is not supported, thus using 'path' will not always work properly. + Parameters: ~ + • {path} (`string`) + • {expr} (`string`) + • {nosuf} (`boolean?`) + • {list} (`boolean?`) + • {allinks} (`boolean?`) + + Return: ~ + (`any`) + has({feature}) *has()* Returns 1 if {feature} is supported, 0 otherwise. The {feature} argument is a feature name like "nvim-0.2.1" or @@ -3366,11 +4568,24 @@ has({feature}) *has()* endif < + Parameters: ~ + • {feature} (`string`) + + Return: ~ + (`0|1`) + has_key({dict}, {key}) *has_key()* The result is a Number, which is TRUE if |Dictionary| {dict} has an entry with key {key}. FALSE otherwise. The {key} argument is a string. + Parameters: ~ + • {dict} (`table`) + • {key} (`string`) + + Return: ~ + (`0|1`) + haslocaldir([{winnr} [, {tabnr}]]) *haslocaldir()* The result is a Number, which is 1 when the window has set a local path via |:lcd| or when {winnr} is -1 and the tabpage @@ -3388,6 +4603,13 @@ haslocaldir([{winnr} [, {tabnr}]]) *haslocaldir()* If {winnr} is -1 it is ignored, only the tab is resolved. Throw error if the arguments are invalid. |E5000| |E5001| |E5002| + Parameters: ~ + • {winnr} (`integer?`) + • {tabnr} (`integer?`) + + Return: ~ + (`0|1`) + hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()* The result is a Number, which is TRUE if there is a mapping that contains {what} in somewhere in the rhs (what it is @@ -3419,6 +4641,14 @@ hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()* < This installs the mapping to "\ABCdoit" only if there isn't already a mapping to "\ABCdoit". + Parameters: ~ + • {what} (`any`) + • {mode} (`string?`) + • {abbr} (`boolean?`) + + Return: ~ + (`0|1`) + histadd({history}, {item}) *histadd()* Add the String {item} to the history {history} which can be one of: *hist-names* @@ -3440,6 +4670,13 @@ histadd({history}, {item}) *histadd()* let date=input("Enter date: ") < This function is not available in the |sandbox|. + Parameters: ~ + • {history} (`string`) + • {item} (`any`) + + Return: ~ + (`0|1`) + histdel({history} [, {item}]) *histdel()* Clear {history}, i.e. delete all its entries. See |hist-names| for the possible values of {history}. @@ -3473,6 +4710,13 @@ histdel({history} [, {item}]) *histdel()* let @/ = histget("search", -1) < + Parameters: ~ + • {history} (`string`) + • {item} (`any?`) + + Return: ~ + (`0|1`) + histget({history} [, {index}]) *histget()* The result is a String, the entry with Number {index} from {history}. See |hist-names| for the possible values of @@ -3489,6 +4733,13 @@ histget({history} [, {index}]) *histget()* command -nargs=1 H execute histget("cmd", 0+<args>) < + Parameters: ~ + • {history} (`string`) + • {index} (`integer|string?`) + + Return: ~ + (`string`) + histnr({history}) *histnr()* The result is the Number of the current entry in {history}. See |hist-names| for the possible values of {history}. @@ -3496,6 +4747,13 @@ histnr({history}) *histnr()* Example: >vim let inp_index = histnr("expr") +< + + Parameters: ~ + • {history} (`string`) + + Return: ~ + (`integer`) hlID({name}) *hlID()* The result is a Number, which is the ID of the highlight group @@ -3507,6 +4765,12 @@ hlID({name}) *hlID()* echo synIDattr(synIDtrans(hlID("Comment")), "bg") < + Parameters: ~ + • {name} (`string`) + + Return: ~ + (`integer`) + hlexists({name}) *hlexists()* The result is a Number, which is TRUE if a highlight group called {name} exists. This is when the group has been @@ -3514,11 +4778,20 @@ hlexists({name}) *hlexists()* been defined for it, it may also have been used for a syntax item. + Parameters: ~ + • {name} (`string`) + + Return: ~ + (`0|1`) + hostname() *hostname()* The result is a String, which is the name of the machine on which Vim is currently running. Machine names greater than 256 characters long are truncated. + Return: ~ + (`string`) + iconv({string}, {from}, {to}) *iconv()* The result is a String, which is the text {string} converted from encoding {from} to encoding {to}. @@ -3531,6 +4804,14 @@ iconv({string}, {from}, {to}) *iconv()* from/to UCS-2 is automatically changed to use UTF-8. You cannot use UCS-2 in a string anyway, because of the NUL bytes. + Parameters: ~ + • {string} (`string`) + • {from} (`string`) + • {to} (`string`) + + Return: ~ + (`any`) + id({expr}) *id()* Returns a |String| which is a unique identifier of the container type (|List|, |Dict|, |Blob| and |Partial|). It is @@ -3539,7 +4820,7 @@ id({expr}) *id()* Note that `v:_null_string`, `v:_null_list`, `v:_null_dict` and `v:_null_blob` have the same `id()` with different types because they are internally represented as NULL pointers. - `id()` returns a hexadecimal representanion of the pointers to + `id()` returns a hexadecimal representation of the pointers to the containers (i.e. like `0x994a40`), same as `printf("%p", {expr})`, but it is advised against counting on the exact format of the return value. @@ -3548,6 +4829,12 @@ id({expr}) *id()* will not be equal to some other `id()`: new containers may reuse identifiers of the garbage-collected ones. + Parameters: ~ + • {expr} (`any`) + + Return: ~ + (`any`) + indent({lnum}) *indent()* The result is a Number, which is indent of line {lnum} in the current buffer. The indent is counted in spaces, the value @@ -3555,6 +4842,12 @@ indent({lnum}) *indent()* |getline()|. When {lnum} is invalid -1 is returned. + Parameters: ~ + • {lnum} (`integer|string`) + + Return: ~ + (`integer`) + index({object}, {expr} [, {start} [, {ic}]]) *index()* Find {expr} in {object} and return its index. See |indexof()| for using a lambda to select the item. @@ -3581,6 +4874,16 @@ index({object}, {expr} [, {start} [, {ic}]]) *index()* if index(numbers, 123) >= 0 " ... endif +< + + Parameters: ~ + • {object} (`any`) + • {expr} (`any`) + • {start} (`integer?`) + • {ic} (`boolean?`) + + Return: ~ + (`any`) indexof({object}, {expr} [, {opts}]) *indexof()* Returns the index of an item in {object} where {expr} is @@ -3619,9 +4922,26 @@ indexof({object}, {expr} [, {opts}]) *indexof()* echo indexof(l, "v:val.n == 20") echo indexof(l, {i, v -> v.n == 30}) echo indexof(l, "v:val.n == 20", #{startidx: 1}) +< + + Parameters: ~ + • {object} (`any`) + • {expr} (`any`) + • {opts} (`table?`) + + Return: ~ + (`any`) input({prompt} [, {text} [, {completion}]]) *input()* + Parameters: ~ + • {prompt} (`string`) + • {text} (`string?`) + • {completion} (`string?`) + + Return: ~ + (`any`) + input({opts}) The result is a String, which is whatever the user typed on the command-line. The {prompt} argument is either a prompt @@ -3731,6 +5051,13 @@ input({opts}) let g:Foo = input("enter search pattern: ") call inputrestore() endfunction +< + + Parameters: ~ + • {opts} (`table`) + + Return: ~ + (`any`) inputlist({textlist}) *inputlist()* {textlist} must be a |List| of strings. This |List| is @@ -3749,12 +5076,21 @@ inputlist({textlist}) *inputlist()* let color = inputlist(['Select color:', '1. red', \ '2. green', '3. blue']) + Parameters: ~ + • {textlist} (`string[]`) + + Return: ~ + (`any`) + inputrestore() *inputrestore()* Restore typeahead that was saved with a previous |inputsave()|. Should be called the same number of times inputsave() is called. Calling it more often is harmless though. Returns TRUE when there is nothing to restore, FALSE otherwise. + Return: ~ + (`any`) + inputsave() *inputsave()* Preserve typeahead (also from mappings) and clear it, so that a following prompt gets input from the user. Should be @@ -3763,6 +5099,9 @@ inputsave() *inputsave()* many inputrestore() calls. Returns TRUE when out of memory, FALSE otherwise. + Return: ~ + (`any`) + inputsecret({prompt} [, {text}]) *inputsecret()* This function acts much like the |input()| function with but two exceptions: @@ -3774,6 +5113,13 @@ inputsecret({prompt} [, {text}]) *inputsecret()* typed on the command-line in response to the issued prompt. NOTE: Command-line completion is not supported. + Parameters: ~ + • {prompt} (`string`) + • {text} (`string?`) + + Return: ~ + (`any`) + insert({object}, {item} [, {idx}]) *insert()* When {object} is a |List| or a |Blob| insert {item} at the start of it. @@ -3791,6 +5137,14 @@ insert({object}, {item} [, {idx}]) *insert()* Note that when {item} is a |List| it is inserted as a single item. Use |extend()| to concatenate |Lists|. + Parameters: ~ + • {object} (`any`) + • {item} (`any`) + • {idx} (`integer?`) + + Return: ~ + (`any`) + interrupt() *interrupt()* Interrupt script execution. It works more or less like the user typing CTRL-C, most commands won't execute and control @@ -3805,18 +5159,54 @@ interrupt() *interrupt()* au BufWritePre * call s:check_typoname(expand('<amatch>')) < + Return: ~ + (`any`) + invert({expr}) *invert()* Bitwise invert. The argument is converted to a number. A List, Dict or Float argument causes an error. Example: >vim let bits = invert(bits) < + Parameters: ~ + • {expr} (`number`) + + Return: ~ + (`any`) + +isabsolutepath({path}) *isabsolutepath()* + The result is a Number, which is |TRUE| when {path} is an + absolute path. + On Unix, a path is considered absolute when it starts with '/'. + On MS-Windows, it is considered absolute when it starts with an + optional drive prefix and is followed by a '\' or '/'. UNC paths + are always absolute. + Example: >vim + echo isabsolutepath('/usr/share/') " 1 + echo isabsolutepath('./foobar') " 0 + echo isabsolutepath('C:\Windows') " 1 + echo isabsolutepath('foobar') " 0 + echo isabsolutepath('\\remote\file') " 1 +< + + Parameters: ~ + • {path} (`string`) + + Return: ~ + (`0|1`) + isdirectory({directory}) *isdirectory()* The result is a Number, which is |TRUE| when a directory with the name {directory} exists. If {directory} doesn't exist, or isn't a directory, the result is |FALSE|. {directory} is any expression, which is used as a String. + Parameters: ~ + • {directory} (`string`) + + Return: ~ + (`0|1`) + isinf({expr}) *isinf()* Return 1 if {expr} is a positive infinity, or -1 a negative infinity, otherwise 0. >vim @@ -3825,6 +5215,12 @@ isinf({expr}) *isinf()* echo isinf(-1.0 / 0.0) < -1 + Parameters: ~ + • {expr} (`number`) + + Return: ~ + (`1|0|-1`) + islocked({expr}) *islocked()* *E786* The result is a Number, which is |TRUE| when {expr} is the name of a locked variable. @@ -3839,11 +5235,23 @@ islocked({expr}) *islocked()* *E78 < When {expr} is a variable that does not exist you get an error message. Use |exists()| to check for existence. + Parameters: ~ + • {expr} (`any`) + + Return: ~ + (`0|1`) + isnan({expr}) *isnan()* Return |TRUE| if {expr} is a float with value NaN. >vim echo isnan(0.0 / 0.0) < 1 + Parameters: ~ + • {expr} (`number`) + + Return: ~ + (`0|1`) + items({dict}) *items()* Return a |List| with all the key-value pairs of {dict}. Each |List| item is a list with two items: the key of a {dict} @@ -3853,15 +5261,39 @@ items({dict}) *items()* for [key, value] in items(mydict) echo key .. ': ' .. value endfor +< + A List or a String argument is also supported. In these + cases, items() returns a List with the index and the value at + the index. + + Parameters: ~ + • {dict} (`any`) + + Return: ~ + (`any`) jobpid({job}) *jobpid()* Return the PID (process id) of |job-id| {job}. + Parameters: ~ + • {job} (`integer`) + + Return: ~ + (`integer`) + jobresize({job}, {width}, {height}) *jobresize()* Resize the pseudo terminal window of |job-id| {job} to {width} columns and {height} rows. Fails if the job was not started with `"pty":v:true`. + Parameters: ~ + • {job} (`integer`) + • {width} (`integer`) + • {height} (`integer`) + + Return: ~ + (`any`) + jobstart({cmd} [, {opts}]) *jobstart()* Note: Prefer |vim.system()| in Lua (unless using the `pty` option). @@ -3948,6 +5380,13 @@ jobstart({cmd} [, {opts}]) *jobstart()* - -1 if {cmd}[0] is not executable. See also |job-control|, |channel|, |msgpack-rpc|. + Parameters: ~ + • {cmd} (`string|string[]`) + • {opts} (`table?`) + + Return: ~ + (`any`) + jobstop({id}) *jobstop()* Stop |job-id| {id} by sending SIGTERM to the job process. If the process does not terminate after a timeout then SIGKILL @@ -3958,6 +5397,12 @@ jobstop({id}) *jobstop()* Returns 1 for valid job id, 0 for invalid id, including jobs have exited or stopped. + Parameters: ~ + • {id} (`integer`) + + Return: ~ + (`any`) + jobwait({jobs} [, {timeout}]) *jobwait()* Waits for jobs and their |on_exit| handlers to complete. @@ -3979,6 +5424,13 @@ jobwait({jobs} [, {timeout}]) *jobwait()* -2 if the job was interrupted (by |CTRL-C|) -3 if the job-id is invalid + Parameters: ~ + • {jobs} (`integer[]`) + • {timeout} (`integer?`) + + Return: ~ + (`any`) + join({list} [, {sep}]) *join()* Join the items in {list} together into one String. When {sep} is specified it is put in between the items. If @@ -3990,6 +5442,13 @@ join({list} [, {sep}]) *join()* converted into a string like with |string()|. The opposite function is |split()|. + Parameters: ~ + • {list} (`any[]`) + • {sep} (`string?`) + + Return: ~ + (`any`) + json_decode({expr}) *json_decode()* Convert {expr} from JSON object. Accepts |readfile()|-style list as the input, as well as regular string. May output any @@ -4005,6 +5464,12 @@ json_decode({expr}) *json_decode()* recommended and the only one required to be supported. Non-UTF-8 characters are an error. + Parameters: ~ + • {expr} (`any`) + + Return: ~ + (`any`) + json_encode({expr}) *json_encode()* Convert {expr} into a JSON string. Accepts |msgpack-special-dict| as the input. Will not convert @@ -4017,10 +5482,22 @@ json_encode({expr}) *json_encode()* or special escapes like "\t", other are dumped as-is. |Blob|s are converted to arrays of the individual bytes. + Parameters: ~ + • {expr} (`any`) + + Return: ~ + (`any`) + keys({dict}) *keys()* Return a |List| with all the keys of {dict}. The |List| is in arbitrary order. Also see |items()| and |values()|. + Parameters: ~ + • {dict} (`table`) + + Return: ~ + (`any`) + keytrans({string}) *keytrans()* Turn the internal byte representation of keys into a form that can be used for |:map|. E.g. >vim @@ -4028,6 +5505,12 @@ keytrans({string}) *keytrans()* echo keytrans(xx) < <C-Home> + Parameters: ~ + • {string} (`string`) + + Return: ~ + (`any`) + len({expr}) *len()* *E701* The result is a Number, which is the length of the argument. When {expr} is a String or a Number the length in bytes is @@ -4039,6 +5522,12 @@ len({expr}) *len()* *E70 |Dictionary| is returned. Otherwise an error is given and returns zero. + Parameters: ~ + • {expr} (`any`) + + Return: ~ + (`any`) + libcall({libname}, {funcname}, {argument}) *libcall()* *E364* *E368* Call function {funcname} in the run-time library {libname} with single argument {argument}. @@ -4081,6 +5570,14 @@ libcall({libname}, {funcname}, {argument}) *libcall()* *E364* *E Examples: >vim echo libcall("libc.so", "getenv", "HOME") + Parameters: ~ + • {libname} (`string`) + • {funcname} (`string`) + • {argument} (`any`) + + Return: ~ + (`any`) + libcallnr({libname}, {funcname}, {argument}) *libcallnr()* Just like |libcall()|, but used for a function that returns an int instead of a string. @@ -4090,29 +5587,25 @@ libcallnr({libname}, {funcname}, {argument}) *libcallnr()* call libcallnr("libc.so", "sleep", 10) < + Parameters: ~ + • {libname} (`string`) + • {funcname} (`string`) + • {argument} (`any`) + + Return: ~ + (`any`) + line({expr} [, {winid}]) *line()* - The result is a Number, which is the line number of the file - position given with {expr}. The {expr} argument is a string. - The accepted positions are: - . the cursor position - $ the last line in the current buffer - 'x position of mark x (if the mark is not set, 0 is - returned) - w0 first line visible in current window (one if the - display isn't updated, e.g. in silent Ex mode) - w$ last line visible in current window (this is one - less than "w0" if no lines are visible) - 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. - Note that a mark in another file can be used. The line number - then applies to another buffer. + See |getpos()| for accepted positions. + To get the column number use |col()|. To get both use |getpos()|. + With the optional {winid} argument the values are obtained for that window instead of the current window. + Returns 0 for invalid values of {expr} and {winid}. + Examples: >vim echo line(".") " line number of the cursor echo line(".", winid) " idem, in window "winid" @@ -4122,6 +5615,13 @@ line({expr} [, {winid}]) *line()* To jump to the last known position when opening a file see |last-position-jump|. + Parameters: ~ + • {expr} (`string|integer[]`) + • {winid} (`integer?`) + + Return: ~ + (`integer`) + line2byte({lnum}) *line2byte()* Return the byte count from the start of the buffer for line {lnum}. This includes the end-of-line character, depending on @@ -4135,6 +5635,12 @@ line2byte({lnum}) *line2byte()* |getline()|. When {lnum} is invalid -1 is returned. Also see |byte2line()|, |go| and |:goto|. + Parameters: ~ + • {lnum} (`integer`) + + Return: ~ + (`integer`) + lispindent({lnum}) *lispindent()* Get the amount of indent for line {lnum} according the lisp indenting rules, as with 'lisp'. @@ -4142,6 +5648,12 @@ lispindent({lnum}) *lispindent()* relevant. {lnum} is used just like in |getline()|. When {lnum} is invalid, -1 is returned. + Parameters: ~ + • {lnum} (`integer`) + + Return: ~ + (`any`) + list2blob({list}) *list2blob()* Return a Blob concatenating all the number values in {list}. Examples: >vim @@ -4152,6 +5664,12 @@ list2blob({list}) *list2blob()* |blob2list()| does the opposite. + Parameters: ~ + • {list} (`any[]`) + + Return: ~ + (`any`) + list2str({list} [, {utf8}]) *list2str()* Convert each number in {list} to a character string can concatenate them all. Examples: >vim @@ -4168,10 +5686,20 @@ list2str({list} [, {utf8}]) *list2str()* < Returns an empty string on error. + Parameters: ~ + • {list} (`any[]`) + • {utf8} (`boolean?`) + + Return: ~ + (`any`) + localtime() *localtime()* Return the current time, measured as seconds since 1st Jan 1970. See also |strftime()|, |strptime()| and |getftime()|. + Return: ~ + (`any`) + log({expr}) *log()* Return the natural logarithm (base e) of {expr} as a |Float|. {expr} must evaluate to a |Float| or a |Number| in the range @@ -4183,6 +5711,12 @@ log({expr}) *log()* echo log(exp(5)) < 5.0 + Parameters: ~ + • {expr} (`number`) + + Return: ~ + (`any`) + log10({expr}) *log10()* Return the logarithm of Float {expr} to base 10 as a |Float|. {expr} must evaluate to a |Float| or a |Number|. @@ -4193,10 +5727,23 @@ log10({expr}) *log10()* echo log10(0.01) < -2.0 + Parameters: ~ + • {expr} (`number`) + + Return: ~ + (`any`) + luaeval({expr} [, {expr}]) *luaeval()* Evaluate Lua expression {expr} and return its result converted to Vim data structures. See |lua-eval| for more details. + Parameters: ~ + • {expr} (`string`) + • {expr1} (`any[]?`) + + Return: ~ + (`any`) + map({expr1}, {expr2}) *map()* {expr1} must be a |List|, |String|, |Blob| or |Dictionary|. When {expr1} is a |List|| or |Dictionary|, replace each @@ -4251,6 +5798,13 @@ map({expr1}, {expr2}) *map()* When {expr2} is a Funcref errors inside a function are ignored, unless it was defined with the "abort" flag. + Parameters: ~ + • {expr1} (`string|table|any[]`) + • {expr2} (`string|function`) + + Return: ~ + (`any`) + maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()* When {dict} is omitted or zero: Return the rhs of mapping {name} in mode {mode}. The returned String has special @@ -4290,6 +5844,7 @@ maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()* "lhsrawalt" The {lhs} of the mapping as raw bytes, alternate form, only present when it differs from "lhsraw" "rhs" The {rhs} of the mapping as typed. + "callback" Lua function, if RHS was defined as such. "silent" 1 for a |:map-silent| mapping, else 0. "noremap" 1 if the {rhs} of the mapping is not remappable. "script" 1 if mapping was defined with <script>. @@ -4322,6 +5877,16 @@ maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()* This function can be used to map a key even when it's already mapped, and have it do the original mapping too. Sketch: >vim exe 'nnoremap <Tab> ==' .. maparg('<Tab>', 'n') +< + + Parameters: ~ + • {name} (`string`) + • {mode} (`string?`) + • {abbr} (`boolean?`) + • {dict} (`false?`) + + Return: ~ + (`string`) mapcheck({name} [, {mode} [, {abbr}]]) *mapcheck()* Check if there is a mapping that matches with {name} in mode @@ -4356,6 +5921,14 @@ mapcheck({name} [, {mode} [, {abbr}]]) *mapcheck()* < This avoids adding the "_vv" mapping when there already is a mapping for "_v" or for "_vvv". + Parameters: ~ + • {name} (`string`) + • {mode} (`string?`) + • {abbr} (`boolean?`) + + Return: ~ + (`any`) + maplist([{abbr}]) *maplist()* Returns a |List| of all mappings. Each List item is a |Dict|, the same as what is returned by |maparg()|, see @@ -4386,6 +5959,13 @@ maplist([{abbr}]) *maplist()* \ {_, m -> m.lhs == 'xyzzy'})[0].mode_bits ounmap xyzzy echo printf("Operator-pending mode bit: 0x%x", op_bit) +< + + Parameters: ~ + • {abbr} (`0|1?`) + + Return: ~ + (`table[]`) mapnew({expr1}, {expr2}) *mapnew()* Like |map()| but instead of replacing items in {expr1} a new @@ -4393,6 +5973,13 @@ mapnew({expr1}, {expr2}) *mapnew()* unchanged. Items can still be changed by {expr2}, if you don't want that use |deepcopy()| first. + Parameters: ~ + • {expr1} (`any`) + • {expr2} (`any`) + + Return: ~ + (`any`) + mapset({mode}, {abbr}, {dict}) *mapset()* mapset({dict}) Restore a mapping from a dictionary, possibly returned by @@ -4429,6 +6016,13 @@ mapset({dict}) for d in save_maps call mapset(d) endfor +< + + Parameters: ~ + • {dict} (`boolean`) + + Return: ~ + (`any`) match({expr}, {pat} [, {start} [, {count}]]) *match()* When {expr} is a |List| then this returns the index of the @@ -4493,6 +6087,15 @@ match({expr}, {pat} [, {start} [, {count}]]) *match()* zero matches at the start instead of a number of matches further down in the text. + Parameters: ~ + • {expr} (`string|any[]`) + • {pat} (`string`) + • {start} (`integer?`) + • {count} (`integer?`) + + Return: ~ + (`any`) + *matchadd()* *E798* *E799* *E801* *E957* matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]]) Defines a pattern to be highlighted in the current window (a @@ -4552,13 +6155,23 @@ matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]]) available from |getmatches()|. All matches can be deleted in one operation by |clearmatches()|. + Parameters: ~ + • {group} (`integer|string`) + • {pattern} (`string`) + • {priority} (`integer?`) + • {id} (`integer?`) + • {dict} (`string?`) + + Return: ~ + (`any`) + matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]]) *matchaddpos()* Same as |matchadd()|, but requires a list of positions {pos} instead of a pattern. This command is faster than |matchadd()| - because it does not require to handle regular expressions and - sets buffer line boundaries to redraw screen. It is supposed - to be used when fast match additions and deletions are - required, for example to highlight matching parentheses. + because it does not handle regular expressions and it sets + buffer line boundaries to redraw screen. It is supposed to be + used when fast match additions and deletions are required, for + example to highlight matching parentheses. *E5030* *E5031* {pos} is a list of positions. Each position can be one of these: @@ -4589,6 +6202,16 @@ matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]]) *matchaddpos()* < Matches added by |matchaddpos()| are returned by |getmatches()|. + Parameters: ~ + • {group} (`integer|string`) + • {pos} (`any[]`) + • {priority} (`integer?`) + • {id} (`integer?`) + • {dict} (`string?`) + + Return: ~ + (`any`) + matcharg({nr}) *matcharg()* Selects the {nr} match item, as set with a |:match|, |:2match| or |:3match| command. @@ -4601,6 +6224,12 @@ matcharg({nr}) *matcharg()* Highlighting matches using the |:match| commands are limited to three matches. |matchadd()| does not have this limitation. + Parameters: ~ + • {nr} (`integer`) + + Return: ~ + (`any`) + matchbufline({buf}, {pat}, {lnum}, {end}, [, {dict}]) *matchbufline()* Returns the |List| of matches in lines from {lnum} to {end} in buffer {buf} where {pat} matches. @@ -4629,22 +6258,32 @@ matchbufline({buf}, {pat}, {lnum}, {end}, [, {dict}]) *matchbufline()* Examples: >vim " Assuming line 3 in buffer 5 contains "a" - :echo matchbufline(5, '\<\k\+\>', 3, 3) - [{'lnum': 3, 'byteidx': 0, 'text': 'a'}] + echo matchbufline(5, '\<\k\+\>', 3, 3) +< `[{'lnum': 3, 'byteidx': 0, 'text': 'a'}]` >vim " Assuming line 4 in buffer 10 contains "tik tok" - :echo matchbufline(10, '\<\k\+\>', 1, 4) - [{'lnum': 4, 'byteidx': 0, 'text': 'tik'}, {'lnum': 4, 'byteidx': 4, 'text': 'tok'}] -< + echo matchbufline(10, '\<\k\+\>', 1, 4) +< `[{'lnum': 4, 'byteidx': 0, 'text': 'tik'}, {'lnum': 4, 'byteidx': 4, 'text': 'tok'}]` + If {submatch} is present and is v:true, then submatches like "\1", "\2", etc. are also returned. Example: >vim " Assuming line 2 in buffer 2 contains "acd" - :echo matchbufline(2, '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2, 2 + echo matchbufline(2, '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2, 2 \ {'submatches': v:true}) - [{'lnum': 2, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}] -< The "submatches" List always contains 9 items. If a submatch +< `[{'lnum': 2, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]` + The "submatches" List always contains 9 items. If a submatch is not found, then an empty string is returned for that submatch. + Parameters: ~ + • {buf} (`string|integer`) + • {pat} (`string`) + • {lnum} (`string|integer`) + • {end_} (`string|integer`) + • {dict} (`table?`) + + Return: ~ + (`any`) + matchdelete({id} [, {win}]) *matchdelete()* *E802* *E803* Deletes a match with ID {id} previously defined by |matchadd()| or one of the |:match| commands. Returns 0 if successful, @@ -4653,6 +6292,13 @@ matchdelete({id} [, {win}]) *matchdelete()* *E802* *E If {win} is specified, use the window with this number or window ID instead of the current window. + Parameters: ~ + • {id} (`integer`) + • {win} (`integer?`) + + Return: ~ + (`any`) + matchend({expr}, {pat} [, {start} [, {count}]]) *matchend()* Same as |match()|, but return the index of first character after the match. Example: >vim @@ -4672,6 +6318,15 @@ matchend({expr}, {pat} [, {start} [, {count}]]) *matchend()* < result is "-1". When {expr} is a |List| the result is equal to |match()|. + Parameters: ~ + • {expr} (`any`) + • {pat} (`string`) + • {start} (`integer?`) + • {count} (`integer?`) + + Return: ~ + (`any`) + matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()* If {list} is a list of strings, then returns a |List| with all the strings in {list} that fuzzy match {str}. The strings in @@ -4735,6 +6390,14 @@ matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()* \ {'matchseq': 1}) < results in `['two one']`. + Parameters: ~ + • {list} (`any[]`) + • {str} (`string`) + • {dict} (`string?`) + + Return: ~ + (`any`) + matchfuzzypos({list}, {str} [, {dict}]) *matchfuzzypos()* Same as |matchfuzzy()|, but returns the list of matched strings, the list of character positions where characters @@ -4757,6 +6420,14 @@ matchfuzzypos({list}, {str} [, {dict}]) *matchfuzzypos()* \ ->matchfuzzypos('ll', {'key' : 'text'}) < results in `[[{"id": 10, "text": "hello"}], [[2, 3]], [127]]` + Parameters: ~ + • {list} (`any[]`) + • {str} (`string`) + • {dict} (`string?`) + + Return: ~ + (`any`) + matchlist({expr}, {pat} [, {start} [, {count}]]) *matchlist()* Same as |match()|, but return a |List|. The first item in the list is the matched string, same as what matchstr() would @@ -4769,6 +6440,15 @@ matchlist({expr}, {pat} [, {start} [, {count}]]) *matchlist()* You can pass in a List, but that is not very useful. + Parameters: ~ + • {expr} (`any`) + • {pat} (`string`) + • {start} (`integer?`) + • {count} (`integer?`) + + Return: ~ + (`any`) + matchstr({expr}, {pat} [, {start} [, {count}]]) *matchstr()* Same as |match()|, but return the matched string. Example: >vim echo matchstr("testing", "ing") @@ -4782,6 +6462,15 @@ matchstr({expr}, {pat} [, {start} [, {count}]]) *matchstr()* When {expr} is a |List| then the matching item is returned. The type isn't changed, it's not necessarily a String. + Parameters: ~ + • {expr} (`any`) + • {pat} (`string`) + • {start} (`integer?`) + • {count} (`integer?`) + + Return: ~ + (`any`) + matchstrlist({list}, {pat} [, {dict}]) *matchstrlist()* Returns the |List| of matches in {list} where {pat} matches. {list} is a |List| of strings. {pat} is matched against each @@ -4801,20 +6490,28 @@ matchstrlist({list}, {pat} [, {dict}]) *matchstrlist()* option settings on the pattern. Example: >vim - :echo matchstrlist(['tik tok'], '\<\k\+\>') - [{'idx': 0, 'byteidx': 0, 'text': 'tik'}, {'idx': 0, 'byteidx': 4, 'text': 'tok'}] - :echo matchstrlist(['a', 'b'], '\<\k\+\>') - [{'idx': 0, 'byteidx': 0, 'text': 'a'}, {'idx': 1, 'byteidx': 0, 'text': 'b'}] -< + echo matchstrlist(['tik tok'], '\<\k\+\>') +< `[{'idx': 0, 'byteidx': 0, 'text': 'tik'}, {'idx': 0, 'byteidx': 4, 'text': 'tok'}]` >vim + echo matchstrlist(['a', 'b'], '\<\k\+\>') +< `[{'idx': 0, 'byteidx': 0, 'text': 'a'}, {'idx': 1, 'byteidx': 0, 'text': 'b'}]` + If "submatches" is present and is v:true, then submatches like "\1", "\2", etc. are also returned. Example: >vim - :echo matchstrlist(['acd'], '\(a\)\?\(b\)\?\(c\)\?\(.*\)', + echo matchstrlist(['acd'], '\(a\)\?\(b\)\?\(c\)\?\(.*\)', \ #{submatches: v:true}) - [{'idx': 0, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}] -< The "submatches" List always contains 9 items. If a submatch +< `[{'idx': 0, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]` + The "submatches" List always contains 9 items. If a submatch is not found, then an empty string is returned for that submatch. + Parameters: ~ + • {list} (`string[]`) + • {pat} (`string`) + • {dict} (`table?`) + + Return: ~ + (`any`) + matchstrpos({expr}, {pat} [, {start} [, {count}]]) *matchstrpos()* Same as |matchstr()|, but return the matched string, the start position and the end position of the match. Example: >vim @@ -4833,6 +6530,15 @@ matchstrpos({expr}, {pat} [, {start} [, {count}]]) *matchstrpos()* < result is ["x", 1, 2, 3]. The type isn't changed, it's not necessarily a String. + Parameters: ~ + • {expr} (`any`) + • {pat} (`string`) + • {start} (`integer?`) + • {count} (`integer?`) + + Return: ~ + (`any`) + max({expr}) *max()* Return the maximum value of all items in {expr}. Example: >vim echo max([apples, pears, oranges]) @@ -4843,6 +6549,12 @@ max({expr}) *max()* items in {expr} cannot be used as a Number this results in an error. An empty |List| or |Dictionary| results in zero. + Parameters: ~ + • {expr} (`any`) + + Return: ~ + (`any`) + menu_get({path} [, {modes}]) *menu_get()* Returns a |List| of |Dictionaries| describing |menus| (defined by |:menu|, |:amenu|, …), including |hidden-menus|. @@ -4889,6 +6601,13 @@ menu_get({path} [, {modes}]) *menu_get()* } ] < + Parameters: ~ + • {path} (`string`) + • {modes} (`string?`) + + Return: ~ + (`any`) + menu_info({name} [, {mode}]) *menu_info()* Return information about the specified menu {name} in mode {mode}. The menu name should be specified without the @@ -4960,6 +6679,13 @@ menu_info({name} [, {mode}]) *menu_info()* endfor < + Parameters: ~ + • {name} (`string`) + • {mode} (`string?`) + + Return: ~ + (`any`) + min({expr}) *min()* Return the minimum value of all items in {expr}. Example: >vim echo min([apples, pears, oranges]) @@ -4970,23 +6696,26 @@ min({expr}) *min()* items in {expr} cannot be used as a Number this results in an error. An empty |List| or |Dictionary| results in zero. + Parameters: ~ + • {expr} (`any`) + + Return: ~ + (`any`) + mkdir({name} [, {flags} [, {prot}]]) *mkdir()* *E739* Create directory {name}. When {flags} is present it must be a string. An empty string has no effect. - If {flags} contains "p" then intermediate directories are - created as necessary. + {flags} can contain these character flags: + "p" intermediate directories will be created as necessary + "D" {name} will be deleted at the end of the current + function, but not recursively |:defer| + "R" {name} will be deleted recursively at the end of the + current function |:defer| - If {flags} contains "D" then {name} is deleted at the end of - the current function, as with: >vim - defer delete({name}, 'd') -< - If {flags} contains "R" then {name} is deleted recursively at - the end of the current function, as with: >vim - defer delete({name}, 'rf') -< Note that when {name} has more than one part and "p" is used + Note that when {name} has more than one part and "p" is used some directories may already exist. Only the first one that is created and what it contains is scheduled to be deleted. E.g. when using: >vim @@ -5013,6 +6742,14 @@ mkdir({name} [, {flags} [, {prot}]]) *mkdir()* *E73 successful or FALSE if the directory creation failed or partly failed. + Parameters: ~ + • {name} (`string`) + • {flags} (`string?`) + • {prot} (`string?`) + + Return: ~ + (`any`) + mode([{expr}]) *mode()* Return a string that indicates the current mode. If {expr} is supplied and it evaluates to a non-zero Number or @@ -5067,6 +6804,12 @@ mode([{expr}]) *mode()* the leading character(s). Also see |visualmode()|. + Parameters: ~ + • {expr} (`any?`) + + Return: ~ + (`any`) + msgpackdump({list} [, {type}]) *msgpackdump()* Convert a list of Vimscript objects to msgpack. Returned value is a |readfile()|-style list. When {type} contains "B", a |Blob| is @@ -5086,6 +6829,13 @@ msgpackdump({list} [, {type}]) *msgpackdump()* 4. Other strings and |Blob|s are always dumped as BIN strings. 5. Points 3. and 4. do not apply to |msgpack-special-dict|s. + Parameters: ~ + • {list} (`any`) + • {type} (`any?`) + + Return: ~ + (`any`) + msgpackparse({data}) *msgpackparse()* Convert a |readfile()|-style list or a |Blob| to a list of Vimscript objects. @@ -5137,12 +6887,7 @@ msgpackparse({data}) *msgpackparse()* C parser does not support such values. float |Float|. This value cannot possibly appear in |msgpackparse()| output. - string |readfile()|-style list of strings. This value will - appear in |msgpackparse()| output if string contains - zero byte or if string is a mapping key and mapping is - being represented as special dictionary for other - reasons. - binary |String|, or |Blob| if binary string contains zero + string |String|, or |Blob| if binary string contains zero byte. This value cannot appear in |msgpackparse()| output since blobs were introduced. array |List|. This value cannot appear in |msgpackparse()| @@ -5159,6 +6904,12 @@ msgpackparse({data}) *msgpackparse()* representing extension type. Second is |readfile()|-style list of strings. + Parameters: ~ + • {data} (`any`) + + Return: ~ + (`any`) + nextnonblank({lnum}) *nextnonblank()* Return the line number of the first line at or below {lnum} that is not blank. Example: >vim @@ -5168,6 +6919,12 @@ nextnonblank({lnum}) *nextnonblank()* {lnum} is used like with |getline()|. See also |prevnonblank()|. + Parameters: ~ + • {lnum} (`integer`) + + Return: ~ + (`any`) + nr2char({expr} [, {utf8}]) *nr2char()* Return a string with a single character, which has the number value {expr}. Examples: >vim @@ -5183,6 +6940,13 @@ nr2char({expr} [, {utf8}]) *nr2char()* characters. nr2char(0) is a real NUL and terminates the string, thus results in an empty string. + Parameters: ~ + • {expr} (`integer`) + • {utf8} (`boolean?`) + + Return: ~ + (`any`) + nvim_...({...}) *nvim_...()* *E5555* *eval-api* Call nvim |api| functions. The type checking of arguments will be stricter than for most other builtins. For instance, @@ -5194,6 +6958,12 @@ nvim_...({...}) *nvim_...()* *E5555* *eval- also take the numerical value 0 to indicate the current (focused) object. + Parameters: ~ + • {...} (`any`) + + Return: ~ + (`any`) + or({expr}, {expr}) *or()* Bitwise OR on the two arguments. The arguments are converted to a number. A List, Dict or Float argument causes an error. @@ -5206,6 +6976,13 @@ or({expr}, {expr}) *or()* to separate commands. In many places it would not be clear if "|" is an operator or a command separator. + Parameters: ~ + • {expr} (`number`) + • {expr1} (`number`) + + Return: ~ + (`any`) + pathshorten({path} [, {len}]) *pathshorten()* Shorten directory names in the path {path} and return the result. The tail, the file name, is kept as-is. The other @@ -5220,6 +6997,13 @@ pathshorten({path} [, {len}]) *pathshorten()* It doesn't matter if the path exists or not. Returns an empty string on error. + Parameters: ~ + • {path} (`string`) + • {len} (`integer?`) + + Return: ~ + (`any`) + perleval({expr}) *perleval()* Evaluate |perl| expression {expr} and return its result converted to Vim data structures. @@ -5235,6 +7019,12 @@ perleval({expr}) *perleval()* echo perleval('[1 .. 4]') < [1, 2, 3, 4] + Parameters: ~ + • {expr} (`any`) + + Return: ~ + (`any`) + pow({x}, {y}) *pow()* Return the power of {x} to the exponent {y} as a |Float|. {x} and {y} must evaluate to a |Float| or a |Number|. @@ -5247,6 +7037,13 @@ pow({x}, {y}) *pow()* echo pow(32, 0.20) < 2.0 + Parameters: ~ + • {x} (`number`) + • {y} (`number`) + + Return: ~ + (`any`) + prevnonblank({lnum}) *prevnonblank()* Return the line number of the first line at or above {lnum} that is not blank. Example: >vim @@ -5256,6 +7053,12 @@ prevnonblank({lnum}) *prevnonblank()* {lnum} is used like with |getline()|. Also see |nextnonblank()|. + Parameters: ~ + • {lnum} (`integer`) + + Return: ~ + (`any`) + printf({fmt}, {expr1} ...) *printf()* Return a String with {fmt}, where "%" items are replaced by the formatted form of their respective arguments. Example: >vim @@ -5579,6 +7382,13 @@ printf({fmt}, {expr1} ...) *printf()* into this, copying the exact format string and parameters that were used. + Parameters: ~ + • {fmt} (`string`) + • {expr1} (`any?`) + + Return: ~ + (`string`) + prompt_getprompt({buf}) *prompt_getprompt()* Returns the effective prompt text for buffer {buf}. {buf} can be a buffer name or number. See |prompt-buffer|. @@ -5586,6 +7396,12 @@ prompt_getprompt({buf}) *prompt_getprompt()* If the buffer doesn't exist or isn't a prompt buffer, an empty string is returned. + Parameters: ~ + • {buf} (`integer|string`) + + Return: ~ + (`any`) + prompt_setcallback({buf}, {expr}) *prompt_setcallback()* Set prompt callback for buffer {buf} to {expr}. When {expr} is an empty string the callback is removed. This has only @@ -5618,6 +7434,13 @@ prompt_setcallback({buf}, {expr}) *prompt_setcallback()* endfunc call prompt_setcallback(bufnr(), function('s:TextEntered')) + Parameters: ~ + • {buf} (`integer|string`) + • {expr} (`string|function`) + + Return: ~ + (`any`) + prompt_setinterrupt({buf}, {expr}) *prompt_setinterrupt()* Set a callback for buffer {buf} to {expr}. When {expr} is an empty string the callback is removed. This has only effect if @@ -5627,6 +7450,13 @@ prompt_setinterrupt({buf}, {expr}) *prompt_setinterrupt()* mode. Without setting a callback Vim will exit Insert mode, as in any buffer. + Parameters: ~ + • {buf} (`integer|string`) + • {expr} (`string|function`) + + Return: ~ + (`any`) + prompt_setprompt({buf}, {text}) *prompt_setprompt()* Set prompt for buffer {buf} to {text}. You most likely want {text} to end in a space. @@ -5635,6 +7465,13 @@ prompt_setprompt({buf}, {text}) *prompt_setprompt()* call prompt_setprompt(bufnr(''), 'command: ') < + Parameters: ~ + • {buf} (`integer|string`) + • {text} (`string`) + + Return: ~ + (`any`) + pum_getpos() *pum_getpos()* If the popup menu (see |ins-completion-menu|) is not visible, returns an empty |Dictionary|, otherwise, returns a @@ -5648,12 +7485,18 @@ pum_getpos() *pum_getpos()* The values are the same as in |v:event| during |CompleteChanged|. + Return: ~ + (`any`) + pumvisible() *pumvisible()* Returns non-zero when the popup menu is visible, zero otherwise. See |ins-completion-menu|. This can be used to avoid some things that would remove the popup menu. + Return: ~ + (`any`) + py3eval({expr}) *py3eval()* Evaluate Python expression {expr} and return its result converted to Vim data structures. @@ -5664,6 +7507,12 @@ py3eval({expr}) *py3eval()* Dictionaries are represented as Vim |Dictionary| type with keys converted to strings. + Parameters: ~ + • {expr} (`any`) + + Return: ~ + (`any`) + pyeval({expr}) *pyeval()* *E858* *E859* Evaluate Python expression {expr} and return its result converted to Vim data structures. @@ -5673,12 +7522,24 @@ pyeval({expr}) *pyeval()* *E858* *E Dictionaries are represented as Vim |Dictionary| type, non-string keys result in error. + Parameters: ~ + • {expr} (`any`) + + Return: ~ + (`any`) + pyxeval({expr}) *pyxeval()* Evaluate Python expression {expr} and return its result converted to Vim data structures. Uses Python 2 or 3, see |python_x| and 'pyxversion'. See also: |pyeval()|, |py3eval()| + Parameters: ~ + • {expr} (`any`) + + Return: ~ + (`any`) + rand([{expr}]) *rand()* Return a pseudo-random Number generated with an xoshiro128** algorithm using seed {expr}. The returned number is 32 bits, @@ -5695,6 +7556,12 @@ rand([{expr}]) *rand()* echo rand(seed) % 16 " random number 0 - 15 < + Parameters: ~ + • {expr} (`number?`) + + Return: ~ + (`any`) + range({expr} [, {max} [, {stride}]]) *range()* *E726* *E727* Returns a |List| with Numbers: - If only {expr} is specified: [0, 1, ..., {expr} - 1] @@ -5714,6 +7581,14 @@ range({expr} [, {max} [, {stride}]]) *range()* *E726* *E echo range(2, 0) " error! < + Parameters: ~ + • {expr} (`any`) + • {max} (`integer?`) + • {stride} (`integer?`) + + Return: ~ + (`any`) + readblob({fname} [, {offset} [, {size}]]) *readblob()* Read file {fname} in binary mode and return a |Blob|. If {offset} is specified, read the file from the specified @@ -5738,6 +7613,14 @@ readblob({fname} [, {offset} [, {size}]]) *readblob()* is truncated. Also see |readfile()| and |writefile()|. + Parameters: ~ + • {fname} (`string`) + • {offset} (`integer?`) + • {size} (`integer?`) + + Return: ~ + (`any`) + readdir({directory} [, {expr}]) *readdir()* Return a list with file and directory names in {directory}. You can also use |glob()| if you don't need to do complicated @@ -5768,6 +7651,13 @@ readdir({directory} [, {expr}]) *readdir()* < Returns an empty List on error. + Parameters: ~ + • {directory} (`string`) + • {expr} (`integer?`) + + Return: ~ + (`any`) + readfile({fname} [, {type} [, {max}]]) *readfile()* Read file {fname} and return a |List|, each line of the file as an item. Lines are broken at NL characters. Macintosh @@ -5801,6 +7691,14 @@ readfile({fname} [, {type} [, {max}]]) *readfile()* the result is an empty list. Also see |writefile()|. + Parameters: ~ + • {fname} (`string`) + • {type} (`string?`) + • {max} (`integer?`) + + Return: ~ + (`any`) + reduce({object}, {func} [, {initial}]) *reduce()* *E998* {func} is called for every item in {object}, which can be a |String|, |List| or a |Blob|. {func} is called with two @@ -5819,20 +7717,37 @@ reduce({object}, {func} [, {initial}]) *reduce()* *E99 echo reduce('xyz', { acc, val -> acc .. ',' .. val }) < + Parameters: ~ + • {object} (`any`) + • {func} (`function`) + • {initial} (`any?`) + + Return: ~ + (`any`) + reg_executing() *reg_executing()* Returns the single letter name of the register being executed. Returns an empty string when no register is being executed. See |@|. + Return: ~ + (`any`) + reg_recorded() *reg_recorded()* Returns the single letter name of the last recorded register. Returns an empty string when nothing was recorded yet. See |q| and |Q|. + Return: ~ + (`any`) + reg_recording() *reg_recording()* Returns the single letter name of the register being recorded. Returns an empty string when not recording. See |q|. + Return: ~ + (`any`) + reltime() *reltime()* reltime({start}) reltime({start}, {end}) @@ -5855,6 +7770,13 @@ reltime({start}, {end}) Note: |localtime()| returns the current (non-relative) time. + Parameters: ~ + • {start} (`any?`) + • {end_} (`any?`) + + Return: ~ + (`any`) + reltimefloat({time}) *reltimefloat()* Return a Float that represents the time value of {time}. Unit of time is seconds. @@ -5866,6 +7788,12 @@ reltimefloat({time}) *reltimefloat()* Also see |profiling|. If there is an error an empty string is returned + Parameters: ~ + • {time} (`any`) + + Return: ~ + (`any`) + reltimestr({time}) *reltimestr()* Return a String that represents the time value of {time}. This is the number of seconds, a dot and the number of @@ -5880,6 +7808,12 @@ reltimestr({time}) *reltimestr()* < Also see |profiling|. If there is an error an empty string is returned + Parameters: ~ + • {time} (`any`) + + Return: ~ + (`any`) + remove({list}, {idx}) *remove()* remove({list}, {idx}, {end}) Without {end}: Remove the item at {idx} from |List| {list} and @@ -5896,6 +7830,14 @@ remove({list}, {idx}, {end}) < Use |delete()| to remove a file. + Parameters: ~ + • {list} (`any[]`) + • {idx} (`integer`) + • {end_} (`integer?`) + + Return: ~ + (`any`) + remove({blob}, {idx}) remove({blob}, {idx}, {end}) Without {end}: Remove the byte at {idx} from |Blob| {blob} and @@ -5910,6 +7852,14 @@ remove({blob}, {idx}, {end}) call remove(mylist, 0, 9) < + Parameters: ~ + • {blob} (`any`) + • {idx} (`integer`) + • {end_} (`integer?`) + + Return: ~ + (`any`) + remove({dict}, {key}) Remove the entry from {dict} with key {key} and return it. Example: >vim @@ -5917,6 +7867,13 @@ remove({dict}, {key}) < If there is no {key} in {dict} this is an error. Returns zero on error. + Parameters: ~ + • {dict} (`any`) + • {key} (`string`) + + Return: ~ + (`any`) + rename({from}, {to}) *rename()* Rename the file by the name {from} to the name {to}. This should also work to move files across file systems. The @@ -5925,6 +7882,13 @@ rename({from}, {to}) *rename()* NOTE: If {to} exists it is overwritten without warning. This function is not available in the |sandbox|. + Parameters: ~ + • {from} (`string`) + • {to} (`string`) + + Return: ~ + (`any`) + repeat({expr}, {count}) *repeat()* Repeat {expr} {count} times and return the concatenated result. Example: >vim @@ -5935,6 +7899,13 @@ repeat({expr}, {count}) *repeat()* let longlist = repeat(['a', 'b'], 3) < Results in ['a', 'b', 'a', 'b', 'a', 'b']. + Parameters: ~ + • {expr} (`any`) + • {count} (`integer`) + + Return: ~ + (`any`) + resolve({filename}) *resolve()* *E655* On MS-Windows, when {filename} is a shortcut (a .lnk file), returns the path the shortcut points to in a simplified form. @@ -5948,6 +7919,12 @@ resolve({filename}) *resolve()* *E65 current directory (provided the result is still a relative path name) and also keeps a trailing path separator. + Parameters: ~ + • {filename} (`string`) + + Return: ~ + (`any`) + reverse({object}) *reverse()* Reverse the order of items in {object}. {object} can be a |List|, a |Blob| or a |String|. For a List and a Blob the @@ -5959,6 +7936,12 @@ reverse({object}) *reverse()* let revlist = reverse(copy(mylist)) < + Parameters: ~ + • {object} (`any`) + + Return: ~ + (`any`) + round({expr}) *round()* Round off {expr} to the nearest integral value and return it as a |Float|. If {expr} lies halfway between two integral @@ -5973,6 +7956,12 @@ round({expr}) *round()* echo round(-4.5) < -5.0 + Parameters: ~ + • {expr} (`number`) + + Return: ~ + (`any`) + rpcnotify({channel}, {event} [, {args}...]) *rpcnotify()* Sends {event} to {channel} via |RPC| and returns immediately. If {channel} is 0, the event is broadcast to all channels. @@ -5980,6 +7969,14 @@ rpcnotify({channel}, {event} [, {args}...]) *rpcnotify()* au VimLeave call rpcnotify(0, "leaving") < + Parameters: ~ + • {channel} (`integer`) + • {event} (`string`) + • {args} (`any?`) + + Return: ~ + (`any`) + rpcrequest({channel}, {method} [, {args}...]) *rpcrequest()* Sends a request to {channel} to invoke {method} via |RPC| and blocks until a response is received. @@ -5987,12 +7984,13 @@ rpcrequest({channel}, {method} [, {args}...]) *rpcrequest()* let result = rpcrequest(rpc_chan, "func", 1, 2, 3) < -rpcstart({prog} [, {argv}]) *rpcstart()* - Deprecated. Replace >vim - let id = rpcstart('prog', ['arg1', 'arg2']) -< with >vim - let id = jobstart(['prog', 'arg1', 'arg2'], {'rpc': v:true}) -< + Parameters: ~ + • {channel} (`integer`) + • {method} (`string`) + • {args} (`any?`) + + Return: ~ + (`any`) rubyeval({expr}) *rubyeval()* Evaluate Ruby expression {expr} and return its result @@ -6004,12 +8002,25 @@ rubyeval({expr}) *rubyeval()* Other objects are represented as strings resulted from their "Object#to_s" method. + Parameters: ~ + • {expr} (`any`) + + Return: ~ + (`any`) + screenattr({row}, {col}) *screenattr()* Like |screenchar()|, but return the attribute. This is a rather arbitrary number that can only be used to compare to the attribute at other positions. Returns -1 when row or col is out of range. + Parameters: ~ + • {row} (`integer`) + • {col} (`integer`) + + Return: ~ + (`any`) + screenchar({row}, {col}) *screenchar()* The result is a Number, which is the character at position [row, col] on the screen. This works for every possible @@ -6020,6 +8031,13 @@ screenchar({row}, {col}) *screenchar()* This is mainly to be used for testing. Returns -1 when row or col is out of range. + Parameters: ~ + • {row} (`integer`) + • {col} (`integer`) + + Return: ~ + (`any`) + screenchars({row}, {col}) *screenchars()* The result is a |List| of Numbers. The first number is the same as what |screenchar()| returns. Further numbers are @@ -6027,6 +8045,13 @@ screenchars({row}, {col}) *screenchars()* This is mainly to be used for testing. Returns an empty List when row or col is out of range. + Parameters: ~ + • {row} (`integer`) + • {col} (`integer`) + + Return: ~ + (`any`) + screencol() *screencol()* The result is a Number, which is the current screen column of the cursor. The leftmost column has number 1. @@ -6039,9 +8064,12 @@ screencol() *screencol()* the following mappings: >vim nnoremap <expr> GG ":echom " .. screencol() .. "\n" nnoremap <silent> GG :echom screencol()<CR> - noremap GG <Cmd>echom screencol()<Cr> + noremap GG <Cmd>echom screencol()<CR> < + Return: ~ + (`any`) + screenpos({winid}, {lnum}, {col}) *screenpos()* The result is a Dict with the screen position of the text character in window {winid} at buffer line {lnum} and column @@ -6066,6 +8094,14 @@ screenpos({winid}, {lnum}, {col}) *screenpos()* first character is returned, {col} is not used. Returns an empty Dict if {winid} is invalid. + Parameters: ~ + • {winid} (`integer`) + • {lnum} (`integer`) + • {col} (`integer`) + + Return: ~ + (`any`) + screenrow() *screenrow()* The result is a Number, which is the current screen row of the cursor. The top line has number one. @@ -6074,6 +8110,9 @@ screenrow() *screenrow()* Note: Same restrictions as with |screencol()|. + Return: ~ + (`any`) + screenstring({row}, {col}) *screenstring()* The result is a String that contains the base character and any composing characters at position [row, col] on the screen. @@ -6082,6 +8121,13 @@ screenstring({row}, {col}) *screenstring()* This is mainly to be used for testing. Returns an empty String when row or col is out of range. + Parameters: ~ + • {row} (`integer`) + • {col} (`integer`) + + Return: ~ + (`any`) + search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) *search()* Search for regexp pattern {pattern}. The search starts at the cursor position (you can use |cursor()| to set it). @@ -6137,6 +8183,9 @@ search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) *search()* The value must not be negative. A zero value is like not giving the argument. + Note: the timeout is only considered when searching, not + while evaluating the {skip} expression. + If the {skip} expression is given it is evaluated with the cursor positioned on the start of a match. If it evaluates to non-zero this match is skipped. This can be used, for @@ -6184,6 +8233,16 @@ search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) *search()* without the 'e' flag if the cursor is on the "f" of "if". The 'n' flag tells the function not to move the cursor. + Parameters: ~ + • {pattern} (`string`) + • {flags} (`string?`) + • {stopline} (`integer?`) + • {timeout} (`integer?`) + • {skip} (`string|function?`) + + Return: ~ + (`any`) + searchcount([{options}]) *searchcount()* Get or update the last search count, like what is displayed without the "S" flag in 'shortmess'. This works even if @@ -6305,6 +8364,12 @@ searchcount([{options}]) *searchcount()* value. see |cursor()|, |getpos()| (default: cursor's position) + Parameters: ~ + • {options} (`table?`) + + Return: ~ + (`any`) + searchdecl({name} [, {global} [, {thisblock}]]) *searchdecl()* Search for the declaration of {name}. @@ -6324,6 +8389,14 @@ searchdecl({name} [, {global} [, {thisblock}]]) *searchdecl()* endif < + Parameters: ~ + • {name} (`string`) + • {global} (`boolean?`) + • {thisblock} (`boolean?`) + + Return: ~ + (`any`) + *searchpair()* searchpair({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeout}]]]]) Search for the match of a nested start-end pair. This can be @@ -6410,6 +8483,18 @@ searchpair({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeo \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"') < + Parameters: ~ + • {start} (`string`) + • {middle} (`string`) + • {end_} (`string`) + • {flags} (`string?`) + • {skip} (`string|function?`) + • {stopline} (`integer?`) + • {timeout} (`integer?`) + + Return: ~ + (`integer`) + *searchpairpos()* searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeout}]]]]) Same as |searchpair()|, but returns a |List| with the line and @@ -6422,6 +8507,18 @@ searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {ti < See |match-parens| for a bigger and more useful example. + Parameters: ~ + • {start} (`string`) + • {middle} (`string`) + • {end_} (`string`) + • {flags} (`string?`) + • {skip} (`string|function?`) + • {stopline} (`integer?`) + • {timeout} (`integer?`) + + Return: ~ + (`[integer, integer]`) + *searchpos()* searchpos({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) Same as |search()|, but returns a |List| with the line and @@ -6438,6 +8535,16 @@ searchpos({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) < In this example "submatch" is 2 when a lowercase letter is found |/\l|, 3 when an uppercase letter is found |/\u|. + Parameters: ~ + • {pattern} (`string`) + • {flags} (`string?`) + • {stopline} (`integer?`) + • {timeout} (`integer?`) + • {skip} (`string|function?`) + + Return: ~ + (`any`) + serverlist() *serverlist()* Returns a list of server addresses, or empty if all servers were stopped. |serverstart()| |serverstop()| @@ -6445,6 +8552,9 @@ serverlist() *serverlist()* echo serverlist() < + Return: ~ + (`any`) + serverstart([{address}]) *serverstart()* Opens a socket or named pipe at {address} and listens for |RPC| messages. Clients can send |API| commands to the @@ -6479,12 +8589,24 @@ serverstart([{address}]) *serverstart()* echo serverstart('::1:12345') < + Parameters: ~ + • {address} (`string?`) + + Return: ~ + (`any`) + serverstop({address}) *serverstop()* Closes the pipe or socket at {address}. Returns TRUE if {address} is valid, else FALSE. If |v:servername| is stopped it is set to the next available address in |serverlist()|. + Parameters: ~ + • {address} (`string`) + + Return: ~ + (`any`) + setbufline({buf}, {lnum}, {text}) *setbufline()* Set line {lnum} to {text} in buffer {buf}. This works like |setline()| for the specified buffer. @@ -6510,6 +8632,14 @@ setbufline({buf}, {lnum}, {text}) *setbufline()* If {buf} is not a valid buffer or {lnum} is not valid, an error message is given. + Parameters: ~ + • {buf} (`integer|string`) + • {lnum} (`integer`) + • {text} (`string|string[]`) + + Return: ~ + (`any`) + setbufvar({buf}, {varname}, {val}) *setbufvar()* Set option or local variable {varname} in buffer {buf} to {val}. @@ -6524,6 +8654,14 @@ setbufvar({buf}, {varname}, {val}) *setbufvar()* call setbufvar("todo", "myvar", "foobar") < This function is not available in the |sandbox|. + Parameters: ~ + • {buf} (`integer|string`) + • {varname} (`string`) + • {val} (`any`) + + Return: ~ + (`any`) + setcellwidths({list}) *setcellwidths()* Specify overrides for cell widths of character ranges. This tells Vim how wide characters are when displayed in the @@ -6552,12 +8690,18 @@ setcellwidths({list}) *setcellwidths()* To clear the overrides pass an empty {list}: >vim call setcellwidths([]) -< You can use the script $VIMRUNTIME/tools/emoji_list.vim to see +< You can use the script $VIMRUNTIME/tools/emoji_list.lua to see the effect for known emoji characters. Move the cursor through the text to check if the cell widths of your terminal match with what Vim knows about each emoji. If it doesn't look right you need to adjust the {list} argument. + Parameters: ~ + • {list} (`any[]`) + + Return: ~ + (`any`) + setcharpos({expr}, {list}) *setcharpos()* Same as |setpos()| but uses the specified column number as the character index instead of the byte index in the line. @@ -6569,6 +8713,13 @@ setcharpos({expr}, {list}) *setcharpos()* call setpos('.', [0, 8, 4, 0]) < positions the cursor on the second character '보'. + Parameters: ~ + • {expr} (`string`) + • {list} (`integer[]`) + + Return: ~ + (`any`) + setcharsearch({dict}) *setcharsearch()* Set the current character search information to {dict}, which contains one or more of the following entries: @@ -6589,6 +8740,12 @@ setcharsearch({dict}) *setcharsearch()* call setcharsearch(prevsearch) < Also see |getcharsearch()|. + Parameters: ~ + • {dict} (`string`) + + Return: ~ + (`any`) + setcmdline({str} [, {pos}]) *setcmdline()* Set the command line to {str} and set the cursor position to {pos}. @@ -6596,6 +8753,13 @@ setcmdline({str} [, {pos}]) *setcmdline()* Returns 0 when successful, 1 when not editing the command line. + Parameters: ~ + • {str} (`string`) + • {pos} (`integer?`) + + Return: ~ + (`any`) + setcmdpos({pos}) *setcmdpos()* Set the cursor position in the command line to byte position {pos}. The first position is 1. @@ -6611,6 +8775,12 @@ setcmdpos({pos}) *setcmdpos()* Returns 0 when successful, 1 when not editing the command line. + Parameters: ~ + • {pos} (`integer`) + + Return: ~ + (`any`) + setcursorcharpos({lnum}, {col} [, {off}]) *setcursorcharpos()* setcursorcharpos({list}) Same as |cursor()| but uses the specified column number as the @@ -6623,6 +8793,12 @@ setcursorcharpos({list}) call cursor(4, 3) < positions the cursor on the first character '여'. + Parameters: ~ + • {list} (`integer[]`) + + Return: ~ + (`any`) + setenv({name}, {val}) *setenv()* Set environment variable {name} to {val}. Example: >vim call setenv('HOME', '/home/myhome') @@ -6630,6 +8806,13 @@ setenv({name}, {val}) *setenv()* < When {val} is |v:null| the environment variable is deleted. See also |expr-env|. + Parameters: ~ + • {name} (`string`) + • {val} (`string`) + + Return: ~ + (`any`) + setfperm({fname}, {mode}) *setfperm()* *chmod* Set the file permissions for {fname} to {mode}. {mode} must be a string with 9 characters. It is of the form @@ -6647,6 +8830,13 @@ setfperm({fname}, {mode}) *setfperm()* *chmo To read permissions see |getfperm()|. + Parameters: ~ + • {fname} (`string`) + • {mode} (`string`) + + Return: ~ + (`any`) + setline({lnum}, {text}) *setline()* Set line {lnum} of the current buffer to {text}. To insert lines use |append()|. To set lines in another buffer use @@ -6675,6 +8865,13 @@ setline({lnum}, {text}) *setline()* < Note: The '[ and '] marks are not set. + Parameters: ~ + • {lnum} (`integer`) + • {text} (`any`) + + Return: ~ + (`any`) + setloclist({nr}, {list} [, {action} [, {what}]]) *setloclist()* Create or replace or add to the location list for window {nr}. {nr} can be the window number or the |window-ID|. @@ -6691,6 +8888,15 @@ setloclist({nr}, {list} [, {action} [, {what}]]) *setloclist()* only the items listed in {what} are set. Refer to |setqflist()| for the list of supported keys in {what}. + Parameters: ~ + • {nr} (`integer`) + • {list} (`any`) + • {action} (`string?`) + • {what} (`table?`) + + Return: ~ + (`any`) + setmatches({list} [, {win}]) *setmatches()* Restores a list of matches saved by |getmatches()| for the current window. Returns 0 if successful, otherwise -1. All @@ -6699,6 +8905,13 @@ setmatches({list} [, {win}]) *setmatches()* If {win} is specified, use the window with this number or window ID instead of the current window. + Parameters: ~ + • {list} (`any`) + • {win} (`integer?`) + + Return: ~ + (`any`) + setpos({expr}, {list}) *setpos()* Set the position for String {expr}. Possible values: . the cursor @@ -6748,6 +8961,13 @@ setpos({expr}, {list}) *setpos()* also set the preferred column. Also see the "curswant" key in |winrestview()|. + Parameters: ~ + • {expr} (`string`) + • {list} (`integer[]`) + + Return: ~ + (`any`) + setqflist({list} [, {action} [, {what}]]) *setqflist()* Create or replace or add to the quickfix list. @@ -6862,6 +9082,14 @@ setqflist({list} [, {action} [, {what}]]) *setqflist()* independent of the 'errorformat' setting. Use a command like `:cc 1` to jump to the first position. + Parameters: ~ + • {list} (`any[]`) + • {action} (`string?`) + • {what} (`table?`) + + Return: ~ + (`any`) + setreg({regname}, {value} [, {options}]) *setreg()* Set the register {regname} to {value}. If {regname} is "" or "@", the unnamed register '"' is used. @@ -6918,6 +9146,14 @@ setreg({regname}, {value} [, {options}]) *setreg()* nothing: >vim call setreg('a', '', 'al') + Parameters: ~ + • {regname} (`string`) + • {value} (`any`) + • {options} (`string?`) + + Return: ~ + (`any`) + settabvar({tabnr}, {varname}, {val}) *settabvar()* Set tab-local variable {varname} to {val} in tab page {tabnr}. |t:var| @@ -6926,6 +9162,14 @@ settabvar({tabnr}, {varname}, {val}) *settabvar()* Tabs are numbered starting with one. This function is not available in the |sandbox|. + Parameters: ~ + • {tabnr} (`integer`) + • {varname} (`string`) + • {val} (`any`) + + Return: ~ + (`any`) + settabwinvar({tabnr}, {winnr}, {varname}, {val}) *settabwinvar()* Set option or local variable {varname} in window {winnr} to {val}. @@ -6942,6 +9186,15 @@ settabwinvar({tabnr}, {winnr}, {varname}, {val}) *settabwinvar()* call settabwinvar(3, 2, "myvar", "foobar") < This function is not available in the |sandbox|. + Parameters: ~ + • {tabnr} (`integer`) + • {winnr} (`integer`) + • {varname} (`string`) + • {val} (`any`) + + Return: ~ + (`any`) + settagstack({nr}, {dict} [, {action}]) *settagstack()* Modify the tag stack of the window {nr} using {dict}. {nr} can be the window number or the |window-ID|. @@ -6976,16 +9229,38 @@ settagstack({nr}, {dict} [, {action}]) *settagstack()* unlet stack < + Parameters: ~ + • {nr} (`integer`) + • {dict} (`any`) + • {action} (`string?`) + + Return: ~ + (`any`) + setwinvar({nr}, {varname}, {val}) *setwinvar()* Like |settabwinvar()| for the current tab page. Examples: >vim call setwinvar(1, "&list", 0) call setwinvar(2, "myvar", "foobar") + Parameters: ~ + • {nr} (`integer`) + • {varname} (`string`) + • {val} (`any`) + + Return: ~ + (`any`) + sha256({string}) *sha256()* Returns a String with 64 hex characters, which is the SHA256 checksum of {string}. + Parameters: ~ + • {string} (`string`) + + Return: ~ + (`any`) + shellescape({string} [, {special}]) *shellescape()* Escape {string} for use as a shell command argument. @@ -7018,6 +9293,13 @@ shellescape({string} [, {special}]) *shellescape()* call system("chmod +w -- " .. shellescape(expand("%"))) < See also |::S|. + Parameters: ~ + • {string} (`string`) + • {special} (`boolean?`) + + Return: ~ + (`any`) + shiftwidth([{col}]) *shiftwidth()* Returns the effective value of 'shiftwidth'. This is the 'shiftwidth' value unless it is zero, in which case it is the @@ -7039,6 +9321,12 @@ shiftwidth([{col}]) *shiftwidth()* 'vartabstop' feature. If no {col} argument is given, column 1 will be assumed. + Parameters: ~ + • {col} (`integer?`) + + Return: ~ + (`integer`) + sign_define({name} [, {dict}]) *sign_define()* sign_define({list}) Define a new sign named {name} or modify the attributes of an @@ -7053,6 +9341,7 @@ sign_define({list}) icon full path to the bitmap file for the sign. linehl highlight group used for the whole line the sign is placed in. + priority default priority value of the sign numhl highlight group used for the line number where the sign is placed. text text that is displayed when there is no icon @@ -7086,6 +9375,12 @@ sign_define({list}) \ ]) < + Parameters: ~ + • {list} (`vim.fn.sign_define.dict[]`) + + Return: ~ + (`(0|-1)[]`) + sign_getdefined([{name}]) *sign_getdefined()* Get a list of defined signs and their attributes. This is similar to the |:sign-list| command. @@ -7100,6 +9395,7 @@ sign_getdefined([{name}]) *sign_getdefined()* linehl highlight group used for the whole line the sign is placed in; not present if not set. name name of the sign + priority default priority value of the sign numhl highlight group used for the line number where the sign is placed; not present if not set. text text that is displayed when there is no icon @@ -7122,6 +9418,12 @@ sign_getdefined([{name}]) *sign_getdefined()* echo sign_getdefined("mySign") < + Parameters: ~ + • {name} (`string?`) + + Return: ~ + (`vim.fn.sign_getdefined.ret.item[]`) + sign_getplaced([{buf} [, {dict}]]) *sign_getplaced()* Return a list of signs placed in a buffer or all the buffers. This is similar to the |:sign-place-list| command. @@ -7183,6 +9485,13 @@ sign_getplaced([{buf} [, {dict}]]) *sign_getplaced()* echo sign_getplaced() < + Parameters: ~ + • {buf} (`integer|string?`) + • {dict} (`vim.fn.sign_getplaced.dict?`) + + Return: ~ + (`vim.fn.sign_getplaced.ret.item[]`) + sign_jump({id}, {group}, {buf}) *sign_jump()* Open the buffer {buf} or jump to the window that contains {buf} and position the cursor at sign {id} in group {group}. @@ -7199,6 +9508,14 @@ sign_jump({id}, {group}, {buf}) *sign_jump()* call sign_jump(10, '', '') < + Parameters: ~ + • {id} (`integer`) + • {group} (`string`) + • {buf} (`integer|string`) + + Return: ~ + (`integer`) + sign_place({id}, {group}, {name}, {buf} [, {dict}]) *sign_place()* Place the sign defined as {name} at line {lnum} in file or buffer {buf} and assign {id} and {group} to sign. This is @@ -7248,6 +9565,16 @@ sign_place({id}, {group}, {name}, {buf} [, {dict}]) *sign_place()* \ {'lnum' : 40, 'priority' : 90}) < + Parameters: ~ + • {id} (`integer`) + • {group} (`string`) + • {name} (`string`) + • {buf} (`integer|string`) + • {dict} (`vim.fn.sign_place.dict?`) + + Return: ~ + (`integer`) + sign_placelist({list}) *sign_placelist()* Place one or more signs. This is similar to the |sign_place()| function. The {list} argument specifies the @@ -7272,7 +9599,8 @@ sign_placelist({list}) *sign_placelist()* priority Priority of the sign. When multiple signs are placed on a line, the sign with the highest priority is used. If not specified, the - default value of 10 is used. See + default value of 10 is used, unless specified + otherwise by the sign definition. See |sign-priority| for more information. If {id} refers to an existing sign, then the existing sign is @@ -7307,6 +9635,12 @@ sign_placelist({list}) *sign_placelist()* \ ]) < + Parameters: ~ + • {list} (`vim.fn.sign_placelist.list.item[]`) + + Return: ~ + (`integer[]`) + sign_undefine([{name}]) *sign_undefine()* sign_undefine({list}) Deletes a previously defined sign {name}. This is similar to @@ -7331,6 +9665,12 @@ sign_undefine({list}) call sign_undefine() < + Parameters: ~ + • {list} (`string[]?`) + + Return: ~ + (`integer[]`) + sign_unplace({group} [, {dict}]) *sign_unplace()* Remove a previously placed sign in one or more buffers. This is similar to the |:sign-unplace| command. @@ -7373,6 +9713,13 @@ sign_unplace({group} [, {dict}]) *sign_unplace()* " Remove all the placed signs from all the buffers call sign_unplace('*') + Parameters: ~ + • {group} (`string`) + • {dict} (`vim.fn.sign_unplace.dict?`) + + Return: ~ + (`0|-1`) + sign_unplacelist({list}) *sign_unplacelist()* Remove previously placed signs from one or more buffers. This is similar to the |sign_unplace()| function. @@ -7402,6 +9749,12 @@ sign_unplacelist({list}) *sign_unplacelist()* \ ]) < + Parameters: ~ + • {list} (`vim.fn.sign_unplacelist.list.item`) + + Return: ~ + (`(0|-1)[]`) + simplify({filename}) *simplify()* Simplify the file name as much as possible without changing the meaning. Shortcuts (on MS-Windows) or symbolic links (on @@ -7419,6 +9772,12 @@ simplify({filename}) *simplify()* directory. In order to resolve all the involved symbolic links before simplifying the path name, use |resolve()|. + Parameters: ~ + • {filename} (`string`) + + Return: ~ + (`any`) + sin({expr}) *sin()* Return the sine of {expr}, measured in radians, as a |Float|. {expr} must evaluate to a |Float| or a |Number|. @@ -7429,6 +9788,12 @@ sin({expr}) *sin()* echo sin(-4.01) < 0.763301 + Parameters: ~ + • {expr} (`number`) + + Return: ~ + (`any`) + sinh({expr}) *sinh()* Return the hyperbolic sine of {expr} as a |Float| in the range [-inf, inf]. @@ -7440,6 +9805,12 @@ sinh({expr}) *sinh()* echo sinh(-0.9) < -1.026517 + Parameters: ~ + • {expr} (`number`) + + Return: ~ + (`any`) + slice({expr}, {start} [, {end}]) *slice()* Similar to using a |slice| "expr[start : end]", but "end" is used exclusive. And for a string the indexes are used as @@ -7450,6 +9821,14 @@ slice({expr}, {start} [, {end}]) *slice()* When {end} is -1 the last item is omitted. Returns an empty value if {start} or {end} are invalid. + Parameters: ~ + • {expr} (`any`) + • {start} (`integer`) + • {end_} (`integer?`) + + Return: ~ + (`any`) + sockconnect({mode}, {address} [, {opts}]) *sockconnect()* Connect a socket to an address. If {mode} is "pipe" then {address} should be the path of a local domain socket (on @@ -7475,6 +9854,14 @@ sockconnect({mode}, {address} [, {opts}]) *sockconnect()* - The channel ID on success (greater than zero) - 0 on invalid arguments or connection failure. + Parameters: ~ + • {mode} (`string`) + • {address} (`string`) + • {opts} (`table?`) + + Return: ~ + (`any`) + sort({list} [, {how} [, {dict}]]) *sort()* *E702* Sort the items in {list} in-place. Returns {list}. @@ -7548,6 +9935,14 @@ sort({list} [, {how} [, {dict}]]) *sort()* *E70 eval mylist->sort({i1, i2 -> i1 - i2}) < + Parameters: ~ + • {list} (`any`) + • {how} (`string|function?`) + • {dict} (`any?`) + + Return: ~ + (`any`) + soundfold({word}) *soundfold()* Return the sound-folded equivalent of {word}. Uses the first language in 'spelllang' for the current window that supports @@ -7556,6 +9951,12 @@ soundfold({word}) *soundfold()* This can be used for making spelling suggestions. Note that the method can be quite slow. + Parameters: ~ + • {word} (`string`) + + Return: ~ + (`any`) + spellbadword([{sentence}]) *spellbadword()* Without argument: The result is the badly spelled word under or after the cursor. The cursor is moved to the start of the @@ -7580,6 +9981,12 @@ spellbadword([{sentence}]) *spellbadword()* The spelling information for the current window and the value of 'spelllang' are used. + Parameters: ~ + • {sentence} (`string?`) + + Return: ~ + (`any`) + spellsuggest({word} [, {max} [, {capital}]]) *spellsuggest()* Return a |List| with spelling suggestions to replace {word}. When {max} is given up to this number of suggestions are @@ -7601,10 +10008,18 @@ spellsuggest({word} [, {max} [, {capital}]]) *spellsuggest()* The spelling information for the current window is used. The values of 'spelllang' and 'spellsuggest' are used. + Parameters: ~ + • {word} (`string`) + • {max} (`integer?`) + • {capital} (`boolean?`) + + Return: ~ + (`any`) + split({string} [, {pattern} [, {keepempty}]]) *split()* Make a |List| out of {string}. When {pattern} is omitted or - empty each white-separated sequence of characters becomes an - item. + empty each white space separated sequence of characters + becomes an item. Otherwise the string is split where {pattern} matches, removing the matched characters. 'ignorecase' is not used here, add \c to ignore case. |/\c| @@ -7626,6 +10041,14 @@ split({string} [, {pattern} [, {keepempty}]]) *split()* let items = split(line, ':', 1) < The opposite function is |join()|. + Parameters: ~ + • {string} (`string`) + • {pattern} (`string?`) + • {keepempty} (`boolean?`) + + Return: ~ + (`any`) + sqrt({expr}) *sqrt()* Return the non-negative square root of Float {expr} as a |Float|. @@ -7639,6 +10062,12 @@ sqrt({expr}) *sqrt()* < str2float("nan") NaN may be different, it depends on system libraries. + Parameters: ~ + • {expr} (`number`) + + Return: ~ + (`any`) + srand([{expr}]) *srand()* Initialize seed used by |rand()|: - If {expr} is not given, seed values are initialized by @@ -7654,6 +10083,12 @@ srand([{expr}]) *srand()* echo rand(seed) < + Parameters: ~ + • {expr} (`number?`) + + Return: ~ + (`any`) + state([{what}]) *state()* Return a string which contains characters indicating the current state. Mostly useful in callbacks that want to do @@ -7684,6 +10119,12 @@ state([{what}]) *state()* recursiveness up to "ccc") s screen has scrolled for messages + Parameters: ~ + • {what} (`string?`) + + Return: ~ + (`any`) + stdioopen({opts}) *stdioopen()* With |--headless| this opens stdin and stdout as a |channel|. May be called only once. See |channel-stdio|. stderr is not @@ -7705,6 +10146,12 @@ stdioopen({opts}) *stdioopen()* - |channel-id| on success (value is always 1) - 0 on invalid arguments + Parameters: ~ + • {opts} (`table`) + + Return: ~ + (`any`) + stdpath({what}) *stdpath()* *E6100* Returns |standard-path| locations of various default files and directories. @@ -7727,6 +10174,13 @@ stdpath({what}) *stdpath()* *E610 echo stdpath("config") < + Parameters: ~ + • {what} + (`'cache'|'config'|'config_dirs'|'data'|'data_dirs'|'log'|'run'|'state'`) + + Return: ~ + (`string|string[]`) + str2float({string} [, {quoted}]) *str2float()* Convert String {string} to a Float. This mostly works the same as when using a floating point number in an expression, @@ -7746,6 +10200,13 @@ str2float({string} [, {quoted}]) *str2float()* < Returns 0.0 if the conversion fails. + Parameters: ~ + • {string} (`string`) + • {quoted} (`boolean?`) + + Return: ~ + (`any`) + str2list({string} [, {utf8}]) *str2list()* Return a list containing the number values which represent each character in String {string}. Examples: >vim @@ -7758,6 +10219,13 @@ str2list({string} [, {utf8}]) *str2list()* With UTF-8 composing characters are handled properly: >vim echo str2list("á") " returns [97, 769] + Parameters: ~ + • {string} (`string`) + • {utf8} (`boolean?`) + + Return: ~ + (`any`) + str2nr({string} [, {base}]) *str2nr()* Convert string {string} to a number. {base} is the conversion base, it can be 2, 8, 10 or 16. @@ -7777,6 +10245,13 @@ str2nr({string} [, {base}]) *str2nr()* Returns 0 if {string} is empty or on error. + Parameters: ~ + • {string} (`string`) + • {base} (`integer?`) + + Return: ~ + (`any`) + strcharlen({string}) *strcharlen()* The result is a Number, which is the number of characters in String {string}. Composing characters are ignored. @@ -7787,6 +10262,12 @@ strcharlen({string}) *strcharlen()* Also see |strlen()|, |strdisplaywidth()| and |strwidth()|. + Parameters: ~ + • {string} (`string`) + + Return: ~ + (`any`) + strcharpart({src}, {start} [, {len} [, {skipcc}]]) *strcharpart()* Like |strpart()| but using character index and length instead of byte index and length. @@ -7802,6 +10283,15 @@ strcharpart({src}, {start} [, {len} [, {skipcc}]]) *strcharpart()* Returns an empty string on error. + Parameters: ~ + • {src} (`string`) + • {start} (`integer`) + • {len} (`integer?`) + • {skipcc} (`boolean?`) + + Return: ~ + (`any`) + strchars({string} [, {skipcc}]) *strchars()* The result is a Number, which is the number of characters in String {string}. @@ -7831,6 +10321,13 @@ strchars({string} [, {skipcc}]) *strchars()* endif < + Parameters: ~ + • {string} (`string`) + • {skipcc} (`boolean?`) + + Return: ~ + (`integer`) + strdisplaywidth({string} [, {col}]) *strdisplaywidth()* The result is a Number, which is the number of display cells String {string} occupies on the screen when it starts at {col} @@ -7845,6 +10342,13 @@ strdisplaywidth({string} [, {col}]) *strdisplaywidth()* Returns zero on error. Also see |strlen()|, |strwidth()| and |strchars()|. + Parameters: ~ + • {string} (`string`) + • {col} (`integer?`) + + Return: ~ + (`integer`) + strftime({format} [, {time}]) *strftime()* The result is a String, which is a formatted date and time, as specified by the {format} string. The given {time} is used, @@ -7862,6 +10366,13 @@ strftime({format} [, {time}]) *strftime()* echo strftime("%c", getftime("file.c")) " Show mod time of file.c. + Parameters: ~ + • {format} (`string`) + • {time} (`number?`) + + Return: ~ + (`string`) + strgetchar({str}, {index}) *strgetchar()* Get a Number corresponding to the character at {index} in {str}. This uses a zero-based character index, not a byte @@ -7871,6 +10382,13 @@ strgetchar({str}, {index}) *strgetchar()* Returns -1 if {index} is invalid. Also see |strcharpart()| and |strchars()|. + Parameters: ~ + • {str} (`string`) + • {index} (`integer`) + + Return: ~ + (`integer`) + stridx({haystack}, {needle} [, {start}]) *stridx()* The result is a Number, which gives the byte index in {haystack} of the first occurrence of the String {needle}. @@ -7890,6 +10408,14 @@ stridx({haystack}, {needle} [, {start}]) *stridx()* stridx() works similar to the C function strstr(). When used with a single character it works similar to strchr(). + Parameters: ~ + • {haystack} (`string`) + • {needle} (`string`) + • {start} (`integer?`) + + Return: ~ + (`integer`) + string({expr}) *string()* Return {expr} converted to a String. If {expr} is a Number, Float, String, Blob or a composition of them, then the result @@ -7914,6 +10440,12 @@ string({expr}) *string()* method. Use |msgpackdump()| or |json_encode()| if you need to share data with other applications. + Parameters: ~ + • {expr} (`any`) + + Return: ~ + (`string`) + strlen({string}) *strlen()* The result is a Number, which is the length of the String {string} in bytes. @@ -7923,6 +10455,12 @@ strlen({string}) *strlen()* |strchars()|. Also see |len()|, |strdisplaywidth()| and |strwidth()|. + Parameters: ~ + • {string} (`string`) + + Return: ~ + (`integer`) + strpart({src}, {start} [, {len} [, {chars}]]) *strpart()* The result is a String, which is part of {src}, starting from byte {start}, with the byte length {len}. @@ -7948,6 +10486,15 @@ strpart({src}, {start} [, {len} [, {chars}]]) *strpart()* < Returns an empty string on error. + Parameters: ~ + • {src} (`string`) + • {start} (`integer`) + • {len} (`integer?`) + • {chars} (`0|1?`) + + Return: ~ + (`string`) + strptime({format}, {timestring}) *strptime()* The result is a Number, which is a unix timestamp representing the date and time in {timestring}, which is expected to match @@ -7972,6 +10519,13 @@ strptime({format}, {timestring}) *strptime()* echo strftime("%c", strptime("%Y%m%d%H%M%S", "19970427115355") + 3600) < Sun Apr 27 12:53:55 1997 + Parameters: ~ + • {format} (`string`) + • {timestring} (`string`) + + Return: ~ + (`integer`) + strridx({haystack}, {needle} [, {start}]) *strridx()* The result is a Number, which gives the byte index in {haystack} of the last occurrence of the String {needle}. @@ -7990,6 +10544,14 @@ strridx({haystack}, {needle} [, {start}]) *strridx()* When used with a single character it works similar to the C function strrchr(). + Parameters: ~ + • {haystack} (`string`) + • {needle} (`string`) + • {start} (`integer?`) + + Return: ~ + (`integer`) + strtrans({string}) *strtrans()* The result is a String, which is {string} with all unprintable characters translated into printable characters |'isprint'|. @@ -8000,6 +10562,12 @@ strtrans({string}) *strtrans()* Returns an empty string on error. + Parameters: ~ + • {string} (`string`) + + Return: ~ + (`string`) + strutf16len({string} [, {countcc}]) *strutf16len()* The result is a Number, which is the number of UTF-16 code units in String {string} (after converting it to UTF-16). @@ -8020,6 +10588,13 @@ strutf16len({string} [, {countcc}]) *strutf16len()* echo strutf16len('ą́', v:true) " returns 3 < + Parameters: ~ + • {string} (`string`) + • {countcc} (`0|1?`) + + Return: ~ + (`integer`) + strwidth({string}) *strwidth()* The result is a Number, which is the number of display cells String {string} occupies. A Tab character is counted as one @@ -8029,6 +10604,12 @@ strwidth({string}) *strwidth()* Returns zero on error. Also see |strlen()|, |strdisplaywidth()| and |strchars()|. + Parameters: ~ + • {string} (`string`) + + Return: ~ + (`integer`) + submatch({nr} [, {list}]) *submatch()* *E935* Only for an expression in a |:substitute| command or substitute() function. @@ -8057,6 +10638,13 @@ submatch({nr} [, {list}]) *submatch()* *E93 < This finds the first number in the line and adds one to it. A line break is included as a newline character. + Parameters: ~ + • {nr} (`integer`) + • {list} (`nil?`) + + Return: ~ + (`string`) + substitute({string}, {pat}, {sub}, {flags}) *substitute()* The result is a String, which is a copy of {string}, in which the first match of {pat} is replaced with {sub}. @@ -8100,6 +10688,15 @@ substitute({string}, {pat}, {sub}, {flags}) *substitute()* < Returns an empty string on error. + Parameters: ~ + • {string} (`string`) + • {pat} (`string`) + • {sub} (`string`) + • {flags} (`string`) + + Return: ~ + (`string`) + swapfilelist() *swapfilelist()* Returns a list of swap file names, like what "vim -r" shows. See the |-r| command argument. The 'directory' option is used @@ -8111,6 +10708,9 @@ swapfilelist() *swapfilelist()* let swapfiles = swapfilelist() let &directory = save_dir + Return: ~ + (`string[]`) + swapinfo({fname}) *swapinfo()* The result is a dictionary, which holds information about the swapfile {fname}. The available fields are: @@ -8129,6 +10729,12 @@ swapinfo({fname}) *swapinfo()* Not a swap file: does not contain correct block ID Magic number mismatch: Info in first block is invalid + Parameters: ~ + • {fname} (`string`) + + Return: ~ + (`any`) + swapname({buf}) *swapname()* The result is the swap file path of the buffer {buf}. For the use of {buf}, see |bufname()| above. @@ -8136,6 +10742,12 @@ swapname({buf}) *swapname()* |:swapname| (unless there is no swap file). If buffer {buf} has no swap file, returns an empty string. + Parameters: ~ + • {buf} (`integer|string`) + + Return: ~ + (`string`) + synID({lnum}, {col}, {trans}) *synID()* The result is a Number, which is the syntax ID at the position {lnum} and {col} in the current window. @@ -8162,6 +10774,14 @@ synID({lnum}, {col}, {trans}) *synID()* echo synIDattr(synID(line("."), col("."), 1), "name") < + Parameters: ~ + • {lnum} (`integer`) + • {col} (`integer`) + • {trans} (`0|1`) + + Return: ~ + (`integer`) + synIDattr({synID}, {what} [, {mode}]) *synIDattr()* The result is a String, which is the {what} attribute of syntax ID {synID}. This can be used to obtain information @@ -8208,6 +10828,14 @@ synIDattr({synID}, {what} [, {mode}]) *synIDattr()* echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg") < + Parameters: ~ + • {synID} (`integer`) + • {what} (`string`) + • {mode} (`string?`) + + Return: ~ + (`string`) + synIDtrans({synID}) *synIDtrans()* The result is a Number, which is the translated syntax ID of {synID}. This is the syntax group ID of what is being used to @@ -8216,6 +10844,12 @@ synIDtrans({synID}) *synIDtrans()* Returns zero on error. + Parameters: ~ + • {synID} (`integer`) + + Return: ~ + (`integer`) + synconcealed({lnum}, {col}) *synconcealed()* The result is a |List| with currently three items: 1. The first item in the list is 0 if the character at the @@ -8245,6 +10879,13 @@ synconcealed({lnum}, {col}) *synconcealed()* since syntax and matching highlighting are two different mechanisms |syntax-vs-match|. + Parameters: ~ + • {lnum} (`integer`) + • {col} (`integer`) + + Return: ~ + (`[integer, string, integer]`) + synstack({lnum}, {col}) *synstack()* Return a |List|, which is the stack of syntax items at the position {lnum} and {col} in the current window. {lnum} is @@ -8264,6 +10905,13 @@ synstack({lnum}, {col}) *synstack()* character in a line and the first column in an empty line are valid positions. + Parameters: ~ + • {lnum} (`integer`) + • {col} (`integer`) + + Return: ~ + (`integer[]`) + system({cmd} [, {input}]) *system()* *E677* Note: Prefer |vim.system()| in Lua. @@ -8313,6 +10961,13 @@ system({cmd} [, {input}]) *system()* *E67 < Unlike ":!cmd" there is no automatic check for changed files. Use |:checktime| to force a check. + Parameters: ~ + • {cmd} (`string|string[]`) + • {input} (`string|string[]|integer?`) + + Return: ~ + (`string`) + systemlist({cmd} [, {input} [, {keepempty}]]) *systemlist()* Same as |system()|, but returns a |List| with lines (parts of output separated by NL) with NULs transformed into NLs. Output @@ -8327,6 +10982,14 @@ systemlist({cmd} [, {input} [, {keepempty}]]) *systemlist()* < Returns an empty string on error. + Parameters: ~ + • {cmd} (`string|string[]`) + • {input} (`string|string[]|integer?`) + • {keepempty} (`integer?`) + + Return: ~ + (`string[]`) + tabpagebuflist([{arg}]) *tabpagebuflist()* The result is a |List|, where each item is the number of the buffer associated with each window in the current tab page. @@ -8340,6 +11003,12 @@ tabpagebuflist([{arg}]) *tabpagebuflist()* endfor < Note that a buffer may appear in more than one window. + Parameters: ~ + • {arg} (`integer?`) + + Return: ~ + (`any`) + tabpagenr([{arg}]) *tabpagenr()* The result is a Number, which is the number of the current tab page. The first tab page has number 1. @@ -8354,6 +11023,12 @@ tabpagenr([{arg}]) *tabpagenr()* Returns zero on error. + Parameters: ~ + • {arg} (`'$'|'#'?`) + + Return: ~ + (`integer`) + tabpagewinnr({tabarg} [, {arg}]) *tabpagewinnr()* Like |winnr()| but for tab page {tabarg}. {tabarg} specifies the number of tab page to be used. @@ -8367,10 +11042,20 @@ tabpagewinnr({tabarg} [, {arg}]) *tabpagewinnr()* tabpagewinnr(4, '$') " number of windows in tab page 4 < When {tabarg} is invalid zero is returned. + Parameters: ~ + • {tabarg} (`integer`) + • {arg} (`'$'|'#'?`) + + Return: ~ + (`integer`) + tagfiles() *tagfiles()* Returns a |List| with the file names used to search for tags for the current buffer. This is the 'tags' option expanded. + Return: ~ + (`string[]`) + taglist({expr} [, {filename}]) *taglist()* Returns a |List| of tags matching the regular expression {expr}. @@ -8414,6 +11099,13 @@ taglist({expr} [, {filename}]) *taglist()* located by Vim. Refer to |tags-file-format| for the format of the tags file generated by the different ctags tools. + Parameters: ~ + • {expr} (`any`) + • {filename} (`string?`) + + Return: ~ + (`any`) + tan({expr}) *tan()* Return the tangent of {expr}, measured in radians, as a |Float| in the range [-inf, inf]. @@ -8425,6 +11117,12 @@ tan({expr}) *tan()* echo tan(-4.01) < -1.181502 + Parameters: ~ + • {expr} (`number`) + + Return: ~ + (`number`) + tanh({expr}) *tanh()* Return the hyperbolic tangent of {expr} as a |Float| in the range [-1, 1]. @@ -8436,6 +11134,12 @@ tanh({expr}) *tanh()* echo tanh(-1) < -0.761594 + Parameters: ~ + • {expr} (`number`) + + Return: ~ + (`number`) + tempname() *tempname()* Generates a (non-existent) filename located in the Nvim root |tempdir|. Scripts can use the filename as a temporary file. @@ -8444,6 +11148,9 @@ tempname() *tempname()* exe "redir > " .. tmpfile < + Return: ~ + (`string`) + termopen({cmd} [, {opts}]) *termopen()* Spawns {cmd} in a new pseudo-terminal session connected to the current (unmodified) buffer. Parameters and behavior @@ -8459,11 +11166,21 @@ termopen({cmd} [, {opts}]) *termopen()* except $TERM is set to "xterm-256color". Full behavior is described in |terminal|. + Parameters: ~ + • {cmd} (`string|string[]`) + • {opts} (`table?`) + + Return: ~ + (`any`) + test_garbagecollect_now() *test_garbagecollect_now()* Like |garbagecollect()|, but executed right away. This must only be called directly to avoid any structure to exist internally, and |v:testing| must have been set before calling - any function. + any function. *E1142* + + Return: ~ + (`any`) timer_info([{id}]) *timer_info()* Return a list with information about timers. @@ -8480,6 +11197,12 @@ timer_info([{id}]) *timer_info()* -1 means forever "callback" the callback + Parameters: ~ + • {id} (`integer?`) + + Return: ~ + (`any`) + timer_pause({timer}, {paused}) *timer_pause()* Pause or unpause a timer. A paused timer does not invoke its callback when its time expires. Unpausing a timer may cause @@ -8493,6 +11216,13 @@ timer_pause({timer}, {paused}) *timer_pause()* String, then the timer is paused, otherwise it is unpaused. See |non-zero-arg|. + Parameters: ~ + • {timer} (`integer`) + • {paused} (`boolean`) + + Return: ~ + (`any`) + timer_start({time}, {callback} [, {options}]) *timer_start()* *timer* Create a timer and return the timer ID. @@ -8523,26 +11253,55 @@ timer_start({time}, {callback} [, {options}]) *timer_start()* *time \ {'repeat': 3}) < This invokes MyHandler() three times at 500 msec intervals. + Parameters: ~ + • {time} (`number`) + • {callback} (`string|function`) + • {options} (`table?`) + + Return: ~ + (`any`) + timer_stop({timer}) *timer_stop()* Stop a timer. The timer callback will no longer be invoked. {timer} is an ID returned by timer_start(), thus it must be a Number. If {timer} does not exist there is no error. + Parameters: ~ + • {timer} (`integer`) + + Return: ~ + (`any`) + timer_stopall() *timer_stopall()* Stop all timers. The timer callbacks will no longer be invoked. Useful if some timers is misbehaving. If there are no timers there is no error. + Return: ~ + (`any`) + tolower({expr}) *tolower()* The result is a copy of the String given, with all uppercase characters turned into lowercase (just like applying |gu| to the string). Returns an empty string on error. + Parameters: ~ + • {expr} (`string`) + + Return: ~ + (`string`) + toupper({expr}) *toupper()* The result is a copy of the String given, with all lowercase characters turned into uppercase (just like applying |gU| to the string). Returns an empty string on error. + Parameters: ~ + • {expr} (`string`) + + Return: ~ + (`string`) + tr({src}, {fromstr}, {tostr}) *tr()* The result is a copy of the {src} string with all characters which appear in {fromstr} replaced by the character in that @@ -8559,6 +11318,14 @@ tr({src}, {fromstr}, {tostr}) *tr()* echo tr("<blob>", "<>", "{}") < returns "{blob}" + Parameters: ~ + • {src} (`string`) + • {fromstr} (`string`) + • {tostr} (`string`) + + Return: ~ + (`string`) + trim({text} [, {mask} [, {dir}]]) *trim()* Return {text} as a String where any character in {mask} is removed from the beginning and/or end of {text}. @@ -8587,6 +11354,14 @@ trim({text} [, {mask} [, {dir}]]) *trim()* echo trim(" vim ", " ", 2) < returns " vim" + Parameters: ~ + • {text} (`string`) + • {mask} (`string?`) + • {dir} (`0|1|2?`) + + Return: ~ + (`string`) + trunc({expr}) *trunc()* Return the largest integral value with magnitude less than or equal to {expr} as a |Float| (truncate towards zero). @@ -8600,6 +11375,12 @@ trunc({expr}) *trunc()* echo trunc(4.0) < 4.0 + Parameters: ~ + • {expr} (`number`) + + Return: ~ + (`integer`) + type({expr}) *type()* The result is a Number representing the type of {expr}. Instead of using the number directly, it is better to use the @@ -8626,6 +11407,13 @@ type({expr}) *type()* if myvar is v:null | endif < To check if the v:t_ variables exist use this: >vim if exists('v:t_number') | endif +< + + Parameters: ~ + • {expr} (`any`) + + Return: ~ + (`integer`) undofile({name}) *undofile()* Return the name of the undo file that would be used for a file @@ -8638,6 +11426,12 @@ undofile({name}) *undofile()* buffer without a file name will not write an undo file. Useful in combination with |:wundo| and |:rundo|. + Parameters: ~ + • {name} (`string`) + + Return: ~ + (`string`) + undotree([{buf}]) *undotree()* Return the current state of the undo tree for the current buffer, or for a specific buffer if {buf} is given. The @@ -8682,6 +11476,12 @@ undotree([{buf}]) *undotree()* blocks. Each item may again have an "alt" item. + Parameters: ~ + • {buf} (`integer|string?`) + + Return: ~ + (`vim.fn.undotree.ret`) + uniq({list} [, {func} [, {dict}]]) *uniq()* *E882* Remove second and succeeding copies of repeated adjacent {list} items in-place. Returns {list}. If you want a list @@ -8692,6 +11492,14 @@ uniq({list} [, {func} [, {dict}]]) *uniq()* *E88 Returns zero if {list} is not a |List|. + Parameters: ~ + • {list} (`any`) + • {func} (`any?`) + • {dict} (`any?`) + + Return: ~ + (`any[]|0`) + utf16idx({string}, {idx} [, {countcc} [, {charidx}]]) *utf16idx()* Same as |charidx()| but returns the UTF-16 code unit index of the byte at {idx} in {string} (after converting it to UTF-16). @@ -8720,11 +11528,26 @@ utf16idx({string}, {idx} [, {countcc} [, {charidx}]]) *utf16idx()* echo utf16idx('a😊😊', 9) " returns -1 < + Parameters: ~ + • {string} (`string`) + • {idx} (`integer`) + • {countcc} (`boolean?`) + • {charidx} (`boolean?`) + + Return: ~ + (`integer`) + values({dict}) *values()* Return a |List| with all the values of {dict}. The |List| is in arbitrary order. Also see |items()| and |keys()|. Returns zero if {dict} is not a |Dict|. + Parameters: ~ + • {dict} (`any`) + + Return: ~ + (`any`) + virtcol({expr} [, {list} [, {winid}]]) *virtcol()* The result is a Number, which is the screen column of the file position given with {expr}. That is, the last screen position @@ -8735,7 +11558,9 @@ virtcol({expr} [, {list} [, {winid}]]) *virtcol()* set to 8, it returns 8. |conceal| is ignored. For the byte position use |col()|. - For the use of {expr} see |col()|. + For the use of {expr} see |getpos()| and |col()|. + When {expr} is "$", it means the end of the cursor line, so + the result is the number of cells in the cursor line plus one. When 'virtualedit' is used {expr} can be [lnum, col, off], where "off" is the offset in screen columns from the start of @@ -8745,18 +11570,6 @@ virtcol({expr} [, {list} [, {winid}]]) *virtcol()* beyond the end of the line can be returned. Also see |'virtualedit'| - The accepted positions are: - . the cursor position - $ the end of the cursor line (the result is the - number of displayed characters 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. - If {list} is present and non-zero then virtcol() returns a List with the first and last screen position occupied by the character. @@ -8775,10 +11588,21 @@ virtcol({expr} [, {list} [, {winid}]]) *virtcol()* " With text " there", with 't at 'h': echo virtcol("'t") " returns 6 -< The first column is 1. 0 or [0, 0] is returned for an error. +< + The first column is 1. 0 or [0, 0] is returned for an error. + A more advanced example that echoes the maximum length of all lines: >vim echo max(map(range(1, line('$')), "virtcol([v:val, '$'])")) +< + + Parameters: ~ + • {expr} (`string|integer[]`) + • {list} (`boolean?`) + • {winid} (`integer?`) + + Return: ~ + (`any`) virtcol2col({winid}, {lnum}, {col}) *virtcol2col()* The result is a Number, which is the byte index of the @@ -8802,6 +11626,14 @@ virtcol2col({winid}, {lnum}, {col}) *virtcol2col()* See also |screenpos()|, |virtcol()| and |col()|. + Parameters: ~ + • {winid} (`integer`) + • {lnum} (`integer`) + • {col} (`integer`) + + Return: ~ + (`any`) + visualmode([{expr}]) *visualmode()* The result is a String, which describes the last Visual mode used in the current buffer. Initially it returns an empty @@ -8820,6 +11652,12 @@ visualmode([{expr}]) *visualmode()* a non-empty String, then the Visual mode will be cleared and the old value is returned. See |non-zero-arg|. + Parameters: ~ + • {expr} (`boolean?`) + + Return: ~ + (`any`) + wait({timeout}, {condition} [, {interval}]) *wait()* Waits until {condition} evaluates to |TRUE|, where {condition} is a |Funcref| or |string| containing an expression. @@ -8836,6 +11674,14 @@ wait({timeout}, {condition} [, {interval}]) *wait()* -2 if the function was interrupted (by |CTRL-C|) -3 if an error occurred + Parameters: ~ + • {timeout} (`integer`) + • {condition} (`any`) + • {interval} (`number?`) + + Return: ~ + (`any`) + wildmenumode() *wildmenumode()* Returns |TRUE| when the wildmenu is active and |FALSE| otherwise. See 'wildmenu' and 'wildmode'. @@ -8847,6 +11693,9 @@ wildmenumode() *wildmenumode()* < (Note, this needs the 'wildcharm' option set appropriately). + Return: ~ + (`any`) + win_execute({id}, {command} [, {silent}]) *win_execute()* Like `execute()` but in the context of window {id}. The window will temporarily be made the current window, @@ -8861,10 +11710,24 @@ win_execute({id}, {command} [, {silent}]) *win_execute()* When window {id} does not exist then no error is given and an empty string is returned. + Parameters: ~ + • {id} (`integer`) + • {command} (`string`) + • {silent} (`boolean?`) + + Return: ~ + (`any`) + win_findbuf({bufnr}) *win_findbuf()* Returns a |List| with |window-ID|s for windows that contain buffer {bufnr}. When there is none the list is empty. + Parameters: ~ + • {bufnr} (`integer`) + + Return: ~ + (`integer[]`) + win_getid([{win} [, {tab}]]) *win_getid()* Get the |window-ID| for the specified window. When {win} is missing use the current window. @@ -8874,6 +11737,13 @@ win_getid([{win} [, {tab}]]) *win_getid()* number {tab}. The first tab has number one. Return zero if the window cannot be found. + Parameters: ~ + • {win} (`integer?`) + • {tab} (`integer?`) + + Return: ~ + (`integer`) + win_gettype([{nr}]) *win_gettype()* Return the type of the window: "autocmd" autocommand window. Temporary window @@ -8892,20 +11762,44 @@ win_gettype([{nr}]) *win_gettype()* Also see the 'buftype' option. + Parameters: ~ + • {nr} (`integer?`) + + Return: ~ + (`'autocmd'|'command'|''|'loclist'|'popup'|'preview'|'quickfix'|'unknown'`) + win_gotoid({expr}) *win_gotoid()* Go to window with ID {expr}. This may also change the current tabpage. Return TRUE if successful, FALSE if the window cannot be found. + Parameters: ~ + • {expr} (`integer`) + + Return: ~ + (`0|1`) + win_id2tabwin({expr}) *win_id2tabwin()* Return a list with the tab number and window number of window with ID {expr}: [tabnr, winnr]. Return [0, 0] if the window cannot be found. + Parameters: ~ + • {expr} (`integer`) + + Return: ~ + (`any`) + win_id2win({expr}) *win_id2win()* Return the window number of window with ID {expr}. Return 0 if the window cannot be found in the current tabpage. + Parameters: ~ + • {expr} (`integer`) + + Return: ~ + (`any`) + win_move_separator({nr}, {offset}) *win_move_separator()* Move window {nr}'s vertical separator (i.e., the right border) by {offset} columns, as if being dragged by the mouse. {nr} @@ -8921,6 +11815,13 @@ win_move_separator({nr}, {offset}) *win_move_separator()* window, since it has no separator on the right. Only works for the current tab page. *E1308* + Parameters: ~ + • {nr} (`integer`) + • {offset} (`integer`) + + Return: ~ + (`any`) + win_move_statusline({nr}, {offset}) *win_move_statusline()* Move window {nr}'s status line (i.e., the bottom border) by {offset} rows, as if being dragged by the mouse. {nr} can be a @@ -8933,6 +11834,13 @@ win_move_statusline({nr}, {offset}) *win_move_statusline()* be found and FALSE otherwise. Only works for the current tab page. + Parameters: ~ + • {nr} (`integer`) + • {offset} (`integer`) + + Return: ~ + (`any`) + win_screenpos({nr}) *win_screenpos()* Return the screen position of window {nr} as a list with two numbers: [row, col]. The first window always has position @@ -8941,6 +11849,12 @@ win_screenpos({nr}) *win_screenpos()* for the current window. Returns [0, 0] if the window cannot be found. + Parameters: ~ + • {nr} (`integer`) + + Return: ~ + (`any`) + win_splitmove({nr}, {target} [, {options}]) *win_splitmove()* Temporarily switch to window {target}, then move window {nr} to a new split adjacent to {target}. @@ -8961,6 +11875,14 @@ win_splitmove({nr}, {target} [, {options}]) *win_splitmove()* present, the values of 'splitbelow' and 'splitright' are used. + Parameters: ~ + • {nr} (`integer`) + • {target} (`integer`) + • {options} (`table?`) + + Return: ~ + (`any`) + winbufnr({nr}) *winbufnr()* The result is a Number, which is the number of the buffer associated with window {nr}. {nr} can be the window number or @@ -8972,17 +11894,29 @@ winbufnr({nr}) *winbufnr()* echo "The file in the current window is " .. bufname(winbufnr(0)) < + Parameters: ~ + • {nr} (`integer`) + + Return: ~ + (`integer`) + wincol() *wincol()* The result is a Number, which is the virtual column of the cursor in the window. This is counting screen cells from the left side of the window. The leftmost column is one. + Return: ~ + (`integer`) + windowsversion() *windowsversion()* The result is a String. For MS-Windows it indicates the OS version. E.g, Windows 10 is "10.0", Windows 8 is "6.2", Windows XP is "5.1". For non-MS-Windows systems the result is an empty string. + Return: ~ + (`string`) + winheight({nr}) *winheight()* The result is a Number, which is the height of window {nr}. {nr} can be the window number or the |window-ID|. @@ -8992,6 +11926,13 @@ winheight({nr}) *winheight()* This excludes any window toolbar line. Examples: >vim echo "The current window has " .. winheight(0) .. " lines." +< + + Parameters: ~ + • {nr} (`integer`) + + Return: ~ + (`integer`) winlayout([{tabnr}]) *winlayout()* The result is a nested List containing the layout of windows @@ -9030,6 +11971,12 @@ winlayout([{tabnr}]) *winlayout()* ['leaf', 1001]]], ['leaf', 1000]]] < + Parameters: ~ + • {tabnr} (`integer?`) + + Return: ~ + (`any`) + winline() *winline()* The result is a Number, which is the screen line of the cursor in the window. This is counting screen lines from the top of @@ -9037,6 +11984,9 @@ winline() *winline()* If the cursor was moved the view on the file will be updated first, this may cause a scroll. + Return: ~ + (`integer`) + winnr([{arg}]) *winnr()* The result is a Number, which is the number of the current window. The top window has number 1. @@ -9067,6 +12017,13 @@ winnr([{arg}]) *winnr()* let window_count = winnr('$') let prev_window = winnr('#') let wnum = winnr('3k') +< + + Parameters: ~ + • {arg} (`string|integer?`) + + Return: ~ + (`any`) winrestcmd() *winrestcmd()* Returns a sequence of |:resize| commands that should restore @@ -9079,6 +12036,9 @@ winrestcmd() *winrestcmd()* exe cmd < + Return: ~ + (`any`) + winrestview({dict}) *winrestview()* Uses the |Dictionary| returned by |winsaveview()| to restore the view of the current window. @@ -9095,6 +12055,12 @@ winrestview({dict}) *winrestview()* If you have changed the values the result is unpredictable. If the window size changed the result won't be the same. + Parameters: ~ + • {dict} (`vim.fn.winrestview.dict`) + + Return: ~ + (`any`) + winsaveview() *winsaveview()* Returns a |Dictionary| that contains information to restore the view of the current window. Use |winrestview()| to @@ -9122,6 +12088,9 @@ winsaveview() *winsaveview()* skipcol columns skipped Note that no option values are saved. + Return: ~ + (`vim.fn.winsaveview.ret`) + winwidth({nr}) *winwidth()* The result is a Number, which is the width of window {nr}. {nr} can be the window number or the |window-ID|. @@ -9136,6 +12105,12 @@ winwidth({nr}) *winwidth()* < For getting the terminal or screen size, see the 'columns' option. + Parameters: ~ + • {nr} (`integer`) + + Return: ~ + (`any`) + wordcount() *wordcount()* The result is a dictionary of byte/chars/word statistics for the current buffer. This is the same info as provided by @@ -9157,6 +12132,9 @@ wordcount() *wordcount()* visual_words Number of words visually selected (only in Visual mode) + Return: ~ + (`any`) + writefile({object}, {fname} [, {flags}]) *writefile()* When {object} is a |List| write it to file {fname}. Each list item is separated with a NL. Each list item must be a String @@ -9202,6 +12180,15 @@ writefile({object}, {fname} [, {flags}]) *writefile()* To copy a file byte for byte: >vim let fl = readfile("foo", "b") call writefile(fl, "foocopy", "b") +< + + Parameters: ~ + • {object} (`any`) + • {fname} (`string`) + • {flags} (`string?`) + + Return: ~ + (`any`) xor({expr}, {expr}) *xor()* Bitwise XOR on the two arguments. The arguments are converted @@ -9211,6 +12198,13 @@ xor({expr}, {expr}) *xor()* let bits = xor(bits, 0x80) < + Parameters: ~ + • {expr} (`number`) + • {expr1} (`number`) + + Return: ~ + (`any`) + ============================================================================== 2. Matching a pattern in a String *string-match* diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt index 9ff16165d7..928b834600 100644 --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -1227,13 +1227,13 @@ Vim fills these registers with text from yank and delete commands. Numbered register 0 contains the text from the most recent yank command, unless the command specified another register with ["x]. Numbered register 1 contains the text deleted by the most recent delete or -change command, unless the command specified another register or the text is -less than one line (the small delete register is used then). An exception is -made for the delete operator with these movement commands: |%|, |(|, |)|, |`|, -|/|, |?|, |n|, |N|, |{| and |}|. Register "1 is always used then (this is Vi -compatible). The "- register is used as well if the delete is within a line. -Note that these characters may be mapped. E.g. |%| is mapped by the matchit -plugin. +change command (even when the command specified another register), unless the +text is less than one line (the small delete register is used then). An +exception is made for the delete operator with these movement commands: |%|, +|(|, |)|, |`|, |/|, |?|, |n|, |N|, |{| and |}|. +Register "1 is always used then (this is Vi compatible). The "- register is +used as well if the delete is within a line. Note that these characters may be +mapped. E.g. |%| is mapped by the matchit plugin. With each successive deletion or change, Vim shifts the previous contents of register 1 into register 2, 2 into 3, and so forth, losing the previous contents of register 9. diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt index f306067a9c..7967e2ce1a 100644 --- a/runtime/doc/cmdline.txt +++ b/runtime/doc/cmdline.txt @@ -348,7 +348,8 @@ terminals) :keepp[atterns] {command} *:keepp* *:keeppatterns* Execute {command}, without adding anything to the search - history + history and, in case of |:s| or |:&|, without modifying the + last substitute pattern or substitute string. ============================================================================== 2. Command-line completion *cmdline-completion* @@ -448,13 +449,13 @@ The 'wildignorecase' option can be set to ignore case in filenames. For completing other texts (e.g. command names), the 'ignorecase' option is used instead (fuzzy matching always ignores case, however). -If you like tcsh's autolist completion, you can use this mapping: +If you like tcsh's autolist completion, you can use this mapping: > :cnoremap X <C-L><C-D> (Where X is the command key to use, <C-L> is CTRL-L and <C-D> is CTRL-D) This will find the longest match and then list all matching files. If you like tcsh's autolist completion, you can use the 'wildmode' option to -emulate it. For example, this mimics autolist=ambiguous: +emulate it. For example, this mimics autolist=ambiguous: > :set wildmode=longest,list This will find the longest match with the first 'wildchar', then list all matching files with the next. diff --git a/runtime/doc/deprecated.txt b/runtime/doc/deprecated.txt index 646ba72bd8..72d2faca02 100644 --- a/runtime/doc/deprecated.txt +++ b/runtime/doc/deprecated.txt @@ -19,6 +19,22 @@ API - nvim_subscribe() Plugins must maintain their own "multicast" channels list. - nvim_unsubscribe() Plugins must maintain their own "multicast" channels list. +LUA +- vim.region() Use |getregionpos()| instead. + +DIAGNOSTICS +- *vim.diagnostic.goto_next()* Use |vim.diagnostic.jump()| with `{count=1, float=true}` instead. +- *vim.diagnostic.goto_prev()* Use |vim.diagnostic.jump()| with `{count=-1, float=true}` instead. +- *vim.diagnostic.get_next_pos()* + Use the "lnum" and "col" fields from the return value of + |vim.diagnostic.get_next()| instead. +- *vim.diagnostic.get_prev_pos()* + Use the "lnum" and "col" fields from the return value of + |vim.diagnostic.get_prev()| instead. +- The "win_id" parameter used by various functions is deprecated in favor of + "winid" |winid| +- The "cursor_position" parameter of |vim.diagnostic.JumpOpts| is renamed to + "pos" ------------------------------------------------------------------------------ DEPRECATED IN 0.10 *deprecated-0.10* @@ -157,6 +173,7 @@ FUNCTIONS - *jobclose()* Obsolete name for |chanclose()| - *jobsend()* Obsolete name for |chansend()| - *last_buffer_nr()* Obsolete name for bufnr("$"). +- *rpcstart()* Use |jobstart()| with `{'rpc': v:true}` instead. - *rpcstop()* Use |jobstop()| instead to stop any job, or `chanclose(id, "rpc")` to close RPC communication without stopping the job. Use chanclose(id) to close @@ -202,9 +219,6 @@ internally and are no longer exposed as part of the API. Instead, use - *vim.lsp.diagnostic.set_underline()* - *vim.lsp.diagnostic.set_virtual_text()* -Configuring |diagnostic-signs| with |:sign-define| or |sign_define()| is no -longer supported. Use the "signs" key of |vim.diagnostic.config()| instead. - LSP FUNCTIONS - *vim.lsp.buf.server_ready()* Use |LspAttach| instead, depending on your use-case. "Server ready" is not diff --git a/runtime/doc/dev_arch.txt b/runtime/doc/dev_arch.txt new file mode 100644 index 0000000000..1cb3b9ad67 --- /dev/null +++ b/runtime/doc/dev_arch.txt @@ -0,0 +1,59 @@ +*dev_arch.txt* Nvim + + + NVIM REFERENCE MANUAL + + +How to develop Nvim, explanation of modules and subsystems *dev-arch* + +The top of each major module has (or should have) an overview in a comment at +the top of its file. The purpose of this document is to give: + +1. an overview of how it all fits together +2. how-to guides for common tasks such as: + - deprecating public functions + - adding a new public (API) function + - adding a new public (UI) event +3. TODO: move src/nvim/README.md into this doc. + + Type |gO| to see the table of contents. + +============================================================================== +Data structures + +Use `kvec.h` for most lists. When you absolutely need a linked list, use +`lib/queue_defs.h` which defines an "intrusive" linked list. + +============================================================================== +UI events + +The source files most directly involved with UI events are: +1. `src/nvim/ui.*`: calls handler functions of registered UI structs (independent from msgpack-rpc) +2. `src/nvim/api/ui.*`: forwards messages over msgpack-rpc to remote UIs. + +UI events are defined in `src/nvim/api/ui_events.in.h` , this file is not +compiled directly, rather it parsed by +`src/nvim/generators/gen_api_ui_events.lua` which autogenerates wrapper +functions used by the source files above. It also generates metadata +accessible as `api_info().ui_events`. + +See commit d3a8e9217f39c59dd7762bd22a76b8bd03ca85ff for an example of adding +a new UI event. + +UI events are deferred to UIs, which implies a deepcopy of the UI event data. + +Remember to bump NVIM_API_LEVEL if it wasn't already during this development +cycle. + +Other references: +* |msgpack-rpc| +* |ui| +* https://github.com/neovim/neovim/pull/3246 +* https://github.com/neovim/neovim/pull/18375 +* https://github.com/neovim/neovim/pull/21605 + + + +============================================================================== + +vim:tw=78:ts=8:sw=4:et:ft=help:norl: diff --git a/runtime/doc/dev_style.txt b/runtime/doc/dev_style.txt index 6c805963a9..32f7279704 100644 --- a/runtime/doc/dev_style.txt +++ b/runtime/doc/dev_style.txt @@ -95,9 +95,9 @@ variable is and what it was initialized to. In particular, initialization should be used instead of declaration and assignment, e.g. >c int i; - i = f(); // BAD: initialization separate from declaration. + i = f(); // ❌: initialization separate from declaration. - int j = g(); // GOOD: declaration has initialization. + int j = g(); // ✅: declaration has initialization. Initialization ~ @@ -107,16 +107,13 @@ but each initialization should be done on a separate line. >c int i; - int j; // GOOD - - int i, j; // GOOD: multiple declarations, no initialization. - + int j; // ✅ + int i, j; // ✅: multiple declarations, no initialization. int i = 0; - int j = 0; // GOOD: one initialization per line. - - int i = 0, j; // BAD: multiple declarations with initialization. + int j = 0; // ✅: one initialization per line. - int i = 0, j = 0; // BAD: multiple declarations with initialization. + int i = 0, j; // ❌: multiple declarations with initialization. + int i = 0, j = 0; // ❌: multiple declarations with initialization. ============================================================================== Nvim-Specific Magic @@ -152,10 +149,10 @@ Postincrement and Postdecrement ~ Use postfix form (`i++`) in statements. >c for (int i = 0; i < 3; i++) { } - int j = ++i; // OK: ++i is used as an expression. + int j = ++i; // ✅: ++i is used as an expression. for (int i = 0; i < 3; ++i) { } - ++i; // BAD: ++i is used as a statement. + ++i; // ❌: ++i is used as a statement. Use of const ~ @@ -217,7 +214,7 @@ Booleans ~ Use `bool` to represent boolean values. >c - int loaded = 1; // BAD: loaded should have type bool. + int loaded = 1; // ❌: loaded should have type bool. Conditions ~ @@ -382,7 +379,7 @@ Filenames should be all lowercase and can include underscores (`_`). Use underscores to separate words. Examples of acceptable file names: > my_useful_file.c - getline_fix.c // OK: getline refers to the glibc function. + getline_fix.c // ✅: getline refers to the glibc function. C files should end in `.c` and header files should end in `.h`. @@ -415,10 +412,10 @@ instance: `my_exciting_local_variable`. For example: >c - string table_name; // OK: uses underscore. - string tablename; // OK: all lowercase. + string table_name; // ✅: uses underscore. + string tablename; // ✅: all lowercase. - string tableName; // BAD: mixed case. + string tableName; // ❌: mixed case. < Struct Variables ~ diff --git a/runtime/doc/dev_tools.txt b/runtime/doc/dev_tools.txt index 52513db31d..efc6ce277a 100644 --- a/runtime/doc/dev_tools.txt +++ b/runtime/doc/dev_tools.txt @@ -7,7 +7,9 @@ Tools and techniques for developing Nvim *dev-tools* The following advice is helpful when working on or debugging issues with Nvim -itself. See also |debug.txt| for advice that applies to Vim. +itself. + +TODO: merge |debug.txt| into here. Type |gO| to see the table of contents. diff --git a/runtime/doc/dev_vimpatch.txt b/runtime/doc/dev_vimpatch.txt index d6e4ced054..5119613b55 100644 --- a/runtime/doc/dev_vimpatch.txt +++ b/runtime/doc/dev_vimpatch.txt @@ -139,7 +139,6 @@ TYPES OF "NOT APPLICABLE" VIM PATCHES ~ - NA files: `src/gui_*`, `src/gvim_*`, `src/GvimExt/*`, `src/testdir/test_gui*` - `balloon` changes: Nvim does not support balloon feature - NA files: `src/beval_*`, `src/testdir/test_balloon_*` -- libvterm changes: Nvim does not vendor libvterm in `src/`. - Screendump tests from `test_popupwin.vim`, `test_popupwin_textprop.vim`: https://github.com/neovim/neovim/pull/12741#issuecomment-704677141 - json changes: incompatible API https://github.com/neovim/neovim/pull/4131 @@ -204,6 +203,8 @@ information. mb_ptr2char utf_ptr2char mb_head_off utf_head_off mb_tail_off utf_cp_bounds + mb_strnicmp2 utf_strnicmp + MB_STRNICMP2 utf_strnicmp mb_lefthalve grid_lefthalve mb_fix_col grid_fix_col utf_off2cells grid_off2cells @@ -302,4 +303,58 @@ used in new documentation: - `{Only when compiled with ...}`: the vast majority of features have been made non-optional (see https://github.com/neovim/neovim/wiki/Introduction) +============================================================================== +FILETYPE DETECTION *dev-vimpatch-filetype* + +Nvim's filetype detection behavior matches Vim, but is implemented as part of +|vim.filetype| (see `$VIMRUNTIME/lua/vim/filetype.lua`). The logic is encoded in +three tables, listed in order of precedence (the first match is returned): +1. `filename` for literal full path or basename lookup; +2. `pattern` for matching filenames or paths against |lua-patterns|, optimized + for fast lookup; +3. `extension` for literal extension lookup. + +Logic that requires checking file contents or buffer variables is implemented +in `$VIMRUNTIME/lua/vim/filetype/detect.lua`. + +When porting filetype patches from Vim, keep the following in mind: + +Prefer explicit filenames or extensions over patterns, especially for case +insensitive matches (see https://github.com/neovim/neovim/pull/29800): > + "*[mM]akefile" regex -> "makefile", "Makefile" filenames + "*.js\c" regex -> "js", "jS", "Js", "jS" extensions + +Pattern matching has several differences: +- It is done using explicit Lua patterns without implicit anchoring instead + of Vim regexes: > + "*/debian/changelog" -> "/debian/changelog$" + "*/bind/db.*" -> "/bind/db%." +< +- Filetype patterns are grouped by their parent pattern to improve matching + performance: If the parent pattern does not match, skip testing all child + patterns. Note that unlike leaf patterns, parent patterns do not have + special matching behaviour if they contain a `/`. + + When adding a new filetype with pattern matching, consider the following: + - If there is already a group with appropriate parent pattern, use it. + - If there can be a fast and specific enough pattern to group at least 3 + filetype patterns, add it as a separate grouped entry. + + New parent patterns should be + - fast: rule of thumb is that it should be a short explicit string + (i.e. no quantifiers or character sets); + - specific: rules of thumb, in order: + - full directory name (e.g., `"/etc/"`, `"/log/"`); + - part of a rare enough directory name (e.g., `"/conf"`, `"git/"`); + - string rarely used in real full paths (e.g., `"nginx"`). + + Example: + - Filetype pattern: `".*/etc/a2ps/.*%.cfg"` + - Good parents: `"/etc/"` or `"%.cfg$"` + - Bad parents: `"%."` (fast but not specific) or `"/a2ps/.*%."` (specific + but slow) + + When modifying an existing regular pattern, make sure that it still fits its + group. + vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/runtime/doc/develop.txt b/runtime/doc/develop.txt index d7837dc2fe..a61c569a67 100644 --- a/runtime/doc/develop.txt +++ b/runtime/doc/develop.txt @@ -7,8 +7,8 @@ Development of Nvim *development* *dev* This reference describes design constraints and guidelines, for developing -Nvim applications or Nvim itself. -Architecture and internal concepts are covered in src/nvim/README.md +Nvim applications or Nvim itself. See |dev-arch| for discussion of Nvim's +architecture and internal concepts. Nvim is free and open source. Everybody is encouraged to contribute. https://github.com/neovim/neovim/blob/master/CONTRIBUTING.md @@ -138,15 +138,15 @@ DOCUMENTATION *dev-doc* - Write docstrings (as opposed to inline comments) with present tense ("Gets"), not imperative ("Get"). This tends to reduce ambiguity and improve clarity by describing "What" instead of "How". > - GOOD: + ✅ OK: /// Gets a highlight definition. - BAD: + ❌ NO: /// Get a highlight definition. - Avoid starting docstrings with "The" or "A" unless needed to avoid ambiguity. This is a visual aid and reduces noise. > - GOOD: + ✅ OK: /// @param dirname Path fragment before `pend` - BAD: + ❌ NO: /// @param dirname The path fragment before `pend` - Vim differences: - Do not prefix help tags with "nvim-". Use |vim_diff.txt| to catalog @@ -247,6 +247,10 @@ Docstring format: - References are written as `[tag]` - Use ``` for code samples. Code samples can be annotated as `vim` or `lua` +- Use `@since <api-level>` to note the |api-level| when the function became + "stable". If `<api-level>` is greater than the current stable release (or + 0), it is marked as "experimental". + - See scripts/util.lua for the mapping of api-level to Nvim version. - Use `@nodoc` to prevent documentation generation. - Use `@inlinedoc` to inline `@class` blocks into `@param` blocks. E.g. >lua @@ -271,7 +275,7 @@ Docstring format: - {somefield}? (integer) Documentation for some field < -- Files which has `@meta` are only used for typing and documentation. +- Files declared as `@meta` are only used for typing and documentation (similar to "*.d.ts" typescript files). Example: the help for |vim.paste()| is generated from a docstring decorating vim.paste in runtime/lua/vim/_editor.lua like this: > @@ -288,6 +292,7 @@ vim.paste in runtime/lua/vim/_editor.lua like this: > --- end)() --- ``` --- + --- @since 12 --- @see |paste| --- --- @param lines ... @@ -307,19 +312,36 @@ See also |dev-naming|. easier to inspect and print, and inherently compatible with all Lua plugins. (This guideline doesn't apply to opaque, non-data objects like `vim.cmd`.) - stdlib functions should follow these common patterns: - - accept iterable instead of table - - exception: in some cases iterable doesn't make sense, e.g. spair() sorts - the input by definition, so there is no reason for it to accept an - iterable, because the input needs to be "reified"; it can't operate on - a "stream". - - return iterable instead of table - - mimic the pairs() or ipairs() interface if the function is intended to be - used in a "for" loop. - - when a result-or-error interface is needed, return `result|nil, nil|errmsg`: > - ---@return Foo|nil # Result object, or nil if not found. - ---@return nil|string # Error message on failure, or nil on success. -< - - Examples: |vim.ui.open()| |io.open()| |luv-error-handling| + - Return |lua-result-or-message| (`any|nil,nil|string`) to communicate + failure, or choose from |dev-error-patterns| when appropriate. + - Accept iterable instead of only table. + - Note: in some cases iterable doesn't make sense, e.g. spair() sorts the + input by definition, so there is no reason for it to accept an iterable, + because the input needs to be "reified"; it can't operate on a "stream". + - Return an iterable (generator) instead of table, if possible. + - Mimic the pairs() or ipairs() interface if the function is intended for + use in a |for-in| loop. + + *dev-error-patterns* +To communicate failure to a consumer, choose from these patterns (in order of +preference): +1. `retval, errmsg` + - When failure is normal, or when it is practical for the consumer to + continue (fallback) in some other way. See |lua-result-or-message|. +2. optional result, no errormsg + - Special case of 1. When there is only a single case of "doesn't exist" + (e.g. cache lookup, dict lookup). +3. `error("no luck")` + - For invalid state ("must not happen"), when failure is exceptional, or at + a low level where the consumers are unlikely to handle it in a meaningful + way. Advantage is that propagation happens for free and it's harder to + accidentally swallow errors. (E.g. using + `uv_handle/pipe:write()` without checking return values is common.) +4. `on_error` parameter + - For async and "visitors" traversing a graph, where many errors may be + collected while work continues. +5. `vim.notify` (sometimes with optional `opts.silent` (async, visitors ^)) + - High-level / application-level messages. End-user invokes these directly. *dev-patterns* Interface conventions ~ @@ -329,13 +351,20 @@ Where possible, these patterns apply to _both_ Lua and the API: - When accepting a buffer id, etc., 0 means "current buffer", nil means "all buffers". Likewise for window id, tabpage id, etc. - Examples: |vim.lsp.codelens.clear()| |vim.diagnostic.enable()| -- Any function signature that accepts a callback function should define the - callback as the LAST parameter, if possible. This improves readability of - calls by placing the less "noisy" arguments near the start. > - GOOD: - filter(table, opts, function() … end) - BAD: - filter(function() … end, table, opts) +- Any function signature that accepts a callback (example: |table.foreach()|) + should place it as the LAST parameter (after opts), if possible (or ALWAYS + for "continuation callbacks"—functions called exactly once). + - Improves readability by placing the less "noisy" arguments near the start. + - Consistent with luv. + - Useful for future async lib which transforms functions of the form + `function(<args>, cb(<ret)>))` => `function(<args>) -> <ret>`. + - Example: >lua + -- ✅ OK: + filter(…, opts, function() … end) + -- ❌ NO: + filter(function() … end, …, opts) + -- ❌ NO: + filter(…, function() … end, opts) - "Enable" ("toggle") interface and behavior: - `enable(…, nil)` and `enable(…, {buf=nil})` are synonyms and control the the "global" enablement of a feature. @@ -566,10 +595,10 @@ a good name: it's idiomatic and unambiguous. If the package is named "neovim", it confuses users, and complicates documentation and discussions. Examples of API-client package names: -- GOOD: nvim-racket -- GOOD: pynvim -- BAD: python-client -- BAD: neovim_ +- ✅ OK: nvim-racket +- ✅ OK: pynvim +- ❌ NO: python-client +- ❌ NO: neovim_ API client implementation guidelines ~ diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt index 36616b9a0d..342947595e 100644 --- a/runtime/doc/diagnostic.txt +++ b/runtime/doc/diagnostic.txt @@ -363,7 +363,6 @@ Lua module: vim.diagnostic *diagnostic-api* • {message} (`string`) The diagnostic text • {source}? (`string`) The source of the diagnostic • {code}? (`string|integer`) The diagnostic code - • {_tags}? (`{ deprecated: boolean, unnecessary: boolean}`) • {user_data}? (`any`) arbitrary data plugins can add • {namespace}? (`integer`) @@ -378,28 +377,38 @@ Lua module: vim.diagnostic *diagnostic-api* • {severity}? (`vim.diagnostic.SeverityFilter`) See |diagnostic-severity|. -*vim.diagnostic.GotoOpts* +*vim.diagnostic.JumpOpts* Extends: |vim.diagnostic.GetOpts| - Configuration table with the following keys: + Configuration table with the keys listed below. Some parameters can have + their default values changed with |vim.diagnostic.config()|. Fields: ~ - • {cursor_position}? (`{[1]:integer,[2]:integer}`, default: current cursor position) - Cursor position as a `(row, col)` tuple. See - |nvim_win_get_cursor()|. - • {wrap}? (`boolean`, default: `true`) Whether to loop - around file or not. Similar to 'wrapscan'. - • {severity}? (`vim.diagnostic.SeverityFilter`) See - |diagnostic-severity|. - • {float}? (`boolean|vim.diagnostic.Opts.Float`, default: - `true`) If `true`, call - |vim.diagnostic.open_float()| after moving. If a - table, pass the table as the {opts} parameter to - |vim.diagnostic.open_float()|. Unless overridden, - the float will show diagnostics at the new cursor - position (as if "cursor" were passed to the - "scope" option). - • {win_id}? (`integer`, default: `0`) Window ID + • {diagnostic}? (`vim.Diagnostic`) The diagnostic to jump to. Mutually + exclusive with {count}, {namespace}, and {severity}. + See |vim.Diagnostic|. + • {count}? (`integer`) The number of diagnostics to move by, + starting from {pos}. A positive integer moves forward + by {count} diagnostics, while a negative integer moves + backward by {count} diagnostics. Mutually exclusive + with {diagnostic}. + • {pos}? (`[integer,integer]`) Cursor position as a `(row, col)` + tuple. See |nvim_win_get_cursor()|. Used to find the + nearest diagnostic when {count} is used. Only used when + {count} is non-nil. Default is the current cursor + position. + • {wrap}? (`boolean`, default: `true`) Whether to loop around + file or not. Similar to 'wrapscan'. + • {severity}? (`vim.diagnostic.SeverityFilter`) See + |diagnostic-severity|. + • {float}? (`boolean|vim.diagnostic.Opts.Float`, default: `false`) + If `true`, call |vim.diagnostic.open_float()| after + moving. If a table, pass the table as the {opts} + parameter to |vim.diagnostic.open_float()|. Unless + overridden, the float will show diagnostics at the new + cursor position (as if "cursor" were passed to the + "scope" option). + • {winid}? (`integer`, default: `0`) Window ID *vim.diagnostic.NS* @@ -410,7 +419,7 @@ Lua module: vim.diagnostic *diagnostic-api* • {disabled}? (`boolean`) *vim.diagnostic.Opts* - Each of the configuration options below accepts one of the following: + Many of the configuration options below accept one of the following: • `false`: Disable this feature • `true`: Enable this feature, use default settings. • `table`: Enable this feature with overrides. Use an empty table to use @@ -441,6 +450,9 @@ Lua module: vim.diagnostic *diagnostic-api* displayed before lower severities (e.g. ERROR is displayed before WARN). Options: • {reverse}? (boolean) Reverse sort order + • {jump}? (`vim.diagnostic.Opts.Jump`) Default values for + |vim.diagnostic.jump()|. See + |vim.diagnostic.Opts.Jump|. *vim.diagnostic.Opts.Float* @@ -454,18 +466,18 @@ Lua module: vim.diagnostic *diagnostic-api* current cursor position (`cursor`). Shorthand versions are also accepted (`c` for `cursor`, `l` for `line`, `b` for `buffer`). - • {pos}? (`integer|{[1]:integer,[2]:integer}`) If {scope} is - "line" or "cursor", use this position rather than - the cursor position. If a number, interpreted as a - line number; otherwise, a (row, col) tuple. + • {pos}? (`integer|[integer,integer]`) If {scope} is "line" + or "cursor", use this position rather than the + cursor position. If a number, interpreted as a line + number; otherwise, a (row, col) tuple. • {severity_sort}? (`boolean|{reverse?:boolean}`, default: `false`) Sort diagnostics by severity. Overrides the setting from |vim.diagnostic.config()|. • {severity}? (`vim.diagnostic.SeverityFilter`) See |diagnostic-severity|. Overrides the setting from |vim.diagnostic.config()|. - • {header}? (`string|{[1]:string,[2]:any}`) String to use as the - header for the floating window. If a table, it is + • {header}? (`string|[string,any]`) String to use as the header + for the floating window. If a table, it is interpreted as a `[text, hl_group]` tuple. Overrides the setting from |vim.diagnostic.config()|. • {source}? (`boolean|'if_many'`) Include the diagnostic source @@ -500,6 +512,17 @@ Lua module: vim.diagnostic *diagnostic-api* • {focus_id}? (`string`) • {border}? (`string`) see |nvim_open_win()|. +*vim.diagnostic.Opts.Jump* + + Fields: ~ + • {float}? (`boolean|vim.diagnostic.Opts.Float`, default: false) + Default value of the {float} parameter of + |vim.diagnostic.jump()|. + • {wrap}? (`boolean`, default: true) Default value of the {wrap} + parameter of |vim.diagnostic.jump()|. + • {severity}? (`vim.diagnostic.SeverityFilter`) Default value of the + {severity} parameter of |vim.diagnostic.jump()|. + *vim.diagnostic.Opts.Signs* Fields: ~ @@ -568,8 +591,7 @@ Lua module: vim.diagnostic *diagnostic-api* < • {hl_mode}? (`'replace'|'combine'|'blend'`) See |nvim_buf_set_extmark()|. - • {virt_text}? (`{[1]:string,[2]:any}[]`) See - |nvim_buf_set_extmark()|. + • {virt_text}? (`[string,any][]`) See |nvim_buf_set_extmark()|. • {virt_text_pos}? (`'eol'|'overlay'|'right_align'|'inline'`) See |nvim_buf_set_extmark()|. • {virt_text_win_col}? (`integer`) See |nvim_buf_set_extmark()|. @@ -678,52 +700,20 @@ get_next({opts}) *vim.diagnostic.get_next()* Get the next diagnostic closest to the cursor position. Parameters: ~ - • {opts} (`vim.diagnostic.GotoOpts?`) See |vim.diagnostic.GotoOpts|. + • {opts} (`vim.diagnostic.JumpOpts?`) See |vim.diagnostic.JumpOpts|. Return: ~ (`vim.Diagnostic?`) Next diagnostic. See |vim.Diagnostic|. -get_next_pos({opts}) *vim.diagnostic.get_next_pos()* - Return the position of the next diagnostic in the current buffer. - - Parameters: ~ - • {opts} (`vim.diagnostic.GotoOpts?`) See |vim.diagnostic.GotoOpts|. - - Return: ~ - (`table|false`) Next diagnostic position as a `(row, col)` tuple or - false if no next diagnostic. - get_prev({opts}) *vim.diagnostic.get_prev()* Get the previous diagnostic closest to the cursor position. Parameters: ~ - • {opts} (`vim.diagnostic.GotoOpts?`) See |vim.diagnostic.GotoOpts|. + • {opts} (`vim.diagnostic.JumpOpts?`) See |vim.diagnostic.JumpOpts|. Return: ~ (`vim.Diagnostic?`) Previous diagnostic. See |vim.Diagnostic|. -get_prev_pos({opts}) *vim.diagnostic.get_prev_pos()* - Return the position of the previous diagnostic in the current buffer. - - Parameters: ~ - • {opts} (`vim.diagnostic.GotoOpts?`) See |vim.diagnostic.GotoOpts|. - - Return: ~ - (`table|false`) Previous diagnostic position as a `(row, col)` tuple - or `false` if there is no prior diagnostic. - -goto_next({opts}) *vim.diagnostic.goto_next()* - Move to the next diagnostic. - - Parameters: ~ - • {opts} (`vim.diagnostic.GotoOpts?`) See |vim.diagnostic.GotoOpts|. - -goto_prev({opts}) *vim.diagnostic.goto_prev()* - Move to the previous diagnostic in the current buffer. - - Parameters: ~ - • {opts} (`vim.diagnostic.GotoOpts?`) See |vim.diagnostic.GotoOpts|. - hide({namespace}, {bufnr}) *vim.diagnostic.hide()* Hide currently displayed diagnostics. @@ -743,6 +733,9 @@ hide({namespace}, {bufnr}) *vim.diagnostic.hide()* is_enabled({filter}) *vim.diagnostic.is_enabled()* Check whether diagnostics are enabled. + Attributes: ~ + Since: 0.10.0 + Parameters: ~ • {filter} (`table?`) Optional filters |kwargs|, or `nil` for all. • {ns_id}? (`integer`) Diagnostic namespace, or `nil` for @@ -753,6 +746,16 @@ is_enabled({filter}) *vim.diagnostic.is_enabled()* Return: ~ (`boolean`) +jump({opts}) *vim.diagnostic.jump()* + Move to a diagnostic. + + Parameters: ~ + • {opts} (`vim.diagnostic.JumpOpts`) See |vim.diagnostic.JumpOpts|. + + Return: ~ + (`vim.Diagnostic?`) The diagnostic that was moved to. See + |vim.Diagnostic|. + *vim.diagnostic.match()* match({str}, {pat}, {groups}, {severity_map}, {defaults}) Parse a diagnostic from a string. @@ -792,7 +795,7 @@ open_float({opts}) *vim.diagnostic.open_float()* Return (multiple): ~ (`integer?`) float_bufnr - (`integer?`) win_id + (`integer?`) winid reset({namespace}, {bufnr}) *vim.diagnostic.reset()* Remove all diagnostics from the given namespace. @@ -831,7 +834,7 @@ setloclist({opts}) *vim.diagnostic.setloclist()* after setting. • {title}? (`string`) Title of the location list. Defaults to "Diagnostics". - • {severity}? (`vim.diagnostic.Severity`) See + • {severity}? (`vim.diagnostic.SeverityFilter`) See |diagnostic-severity|. setqflist({opts}) *vim.diagnostic.setqflist()* @@ -845,7 +848,7 @@ setqflist({opts}) *vim.diagnostic.setqflist()* after setting. • {title}? (`string`) Title of quickfix list. Defaults to "Diagnostics". - • {severity}? (`vim.diagnostic.Severity`) See + • {severity}? (`vim.diagnostic.SeverityFilter`) See |diagnostic-severity|. *vim.diagnostic.show()* diff --git a/runtime/doc/diff.txt b/runtime/doc/diff.txt index 2f174a404e..c9de54342e 100644 --- a/runtime/doc/diff.txt +++ b/runtime/doc/diff.txt @@ -369,6 +369,9 @@ Additionally, 'diffexpr' should take care of "icase" and "iwhite" in the 'diffopt' option. 'diffexpr' cannot change the value of 'lines' and 'columns'. +The advantage of using a function call without arguments is that it is faster, +see |expr-option-function|. + Example (this does almost the same as 'diffexpr' being empty): > set diffexpr=MyDiff() @@ -434,6 +437,9 @@ will have the same effect. These variables are set to the file names used: v:fname_diff patch file v:fname_out resulting patched file +The advantage of using a function call without arguments is that it is faster, +see |expr-option-function|. + Example (this does the same as 'patchexpr' being empty): > set patchexpr=MyPatch() diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt index 662d89895d..0008713025 100644 --- a/runtime/doc/editing.txt +++ b/runtime/doc/editing.txt @@ -646,7 +646,7 @@ list of the current window. Also see |++opt| and |+cmd|. :[count]arga[dd] {name} .. *:arga* *:argadd* *E479* -:[count]arga[dd] +:[count]arga[dd] *E1156* Add the {name}s to the argument list. When {name} is omitted add the current buffer name to the argument list. @@ -714,7 +714,7 @@ list of the current window. omitted the current entry is used. Also see |++opt| and |+cmd|. -:[count]n[ext] [++opt] [+cmd] *:n* *:ne* *:next* *E165* *E163* +:[count]n[ext] [++opt] [+cmd] *:n* *:ne* *:next* *]a* *E165* *E163* Edit [count] next file. This fails when changes have been made and Vim does not want to |abandon| the current buffer. Also see |++opt| and |+cmd|. @@ -740,10 +740,10 @@ list of the current window. any changes to the buffer. Also see |++opt| and |+cmd|. -:[count]prev[ious] [count] [++opt] [+cmd] *:prev* *:previous* +:[count]prev[ious] [count] [++opt] [+cmd] *:prev* *:previous* *[a* Same as :Next. Also see |++opt| and |+cmd|. - *:rew* *:rewind* + *:rew* *:rewind* *[A* :rew[ind] [++opt] [+cmd] Start editing the first file in the argument list. This fails when changes have been made and Vim does @@ -759,7 +759,7 @@ list of the current window. :fir[st][!] [++opt] [+cmd] Other name for ":rewind". - *:la* *:last* + *:la* *:last* *]A* :la[st] [++opt] [+cmd] Start editing the last file in the argument list. This fails when changes have been made and Vim does @@ -1623,7 +1623,7 @@ There are three different types of searching: stop-directories are appended to the path (for the 'path' option) or to the filename (for the 'tags' option) with a ';'. If you want several stop-directories separate them with ';'. If you want no stop-directory - ("search upward till the root directory) just use ';'. > + ("search upward till the root directory") just use ';'. > /usr/include/sys;/usr < will search in: > /usr/include/sys @@ -1636,7 +1636,7 @@ There are three different types of searching: If Vim's current path is /u/user_x/work/release and you do > :set path=include;/u/user_x -< and then search for a file with |gf| the file is searched in: > +< and then search for a file with |gf| the file is searched in: > /u/user_x/work/release/include /u/user_x/work/include /u/user_x/include @@ -1648,7 +1648,7 @@ There are three different types of searching: 3) Combined up/downward search: If Vim's current path is /u/user_x/work/release and you do > set path=**;/u/user_x -< and then search for a file with |gf| the file is searched in: > +< and then search for a file with |gf| the file is searched in: > /u/user_x/work/release/** /u/user_x/work/** /u/user_x/** @@ -1660,10 +1660,10 @@ There are three different types of searching: In the above example you might want to set path to: > :set path=**,/u/user_x/** -< This searches: - /u/user_x/work/release/** ~ - /u/user_x/** ~ - This searches the same directories, but in a different order. +< This searches: > + /u/user_x/work/release/** + /u/user_x/** +< This searches the same directories, but in a different order. Note that completion for ":find", ":sfind", and ":tabfind" commands do not currently work with 'path' items that contain a URL or use the double star diff --git a/runtime/doc/editorconfig.txt b/runtime/doc/editorconfig.txt index 0b20c77801..eef14ed51c 100644 --- a/runtime/doc/editorconfig.txt +++ b/runtime/doc/editorconfig.txt @@ -78,6 +78,10 @@ root *editorconfig.root* directories. This property must be at the top-level of the `.editorconfig` file (i.e. it must not be within a glob section). +spelling_language *editorconfig.spelling_language* + A code of the format ss or ss-TT, where ss is an ISO 639 language code and + TT is an ISO 3166 territory identifier. Sets the 'spelllang' option. + tab_width *editorconfig.tab_width* The display size of a single tab character. Sets the 'tabstop' option. diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 7b4dba5a50..e0c45503cc 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -894,6 +894,9 @@ Example: > All expressions within one level are parsed from left to right. +Expression nesting is limited to 1000 levels deep (300 when build with MSVC) +to avoid running out of stack and crashing. *E1169* + ------------------------------------------------------------------------------ expr1 *expr1* *ternary* *falsy-operator* *??* *E109* @@ -2166,9 +2169,10 @@ text... let lconst[0] = 2 " Error! let lconst[1][0] = 'b' " OK < *E995* - |:const| does not allow to for changing a variable. > + It is an error to specify an existing variable with + |:const|. > :let x = 1 - :const x = 2 " Error! + :const x = 1 " Error! < *E996* Note that environment variables, option values and register values cannot be used here, since they cannot @@ -2186,7 +2190,7 @@ text... :lockvar v :let v = 'asdf' " fails! :unlet v " works -< *E741* *E940* +< *E741* *E940* *E1122* If you try to change a locked variable you get an error message: "E741: Value is locked: {name}". If you try to lock or unlock a built-in variable you diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt index 5eae78744c..a577b0c5fb 100644 --- a/runtime/doc/filetype.txt +++ b/runtime/doc/filetype.txt @@ -147,6 +147,7 @@ variables can be used to overrule the filetype used for certain extensions: `*.csh` g:filetype_csh |ft-csh-syntax| `*.dat` g:filetype_dat `*.def` g:filetype_def + `*.dsp` g:filetype_dsp `*.f` g:filetype_f |ft-forth-syntax| `*.frm` g:filetype_frm |ft-form-syntax| `*.fs` g:filetype_fs |ft-forth-syntax| @@ -585,6 +586,17 @@ any #lang directive overrides, use the following command: > let g:freebasic_lang = "fblite" +GDSCRIPT *ft-gdscript-plugin* + +By default the following options are set, based on Godot official docs: > + + setlocal noexpandtab softtabstop=0 shiftwidth=0 + +To disable this behavior, set the following variable in your vimrc: > + + let g:gdscript_recommended_style = 0 + + GIT COMMIT *ft-gitcommit-plugin* One command, :DiffGitCached, is provided to show a diff of the current commit @@ -592,6 +604,17 @@ in the preview window. It is equivalent to calling "git diff --cached" plus any arguments given to the command. +GO *ft-go-plugin* + +By default the following options are set, based on Golang official docs: > + + setlocal noexpandtab softtabstop=0 shiftwidth=0 + +To disable this behavior, set the following variable in your vimrc: > + + let g:go_recommended_style = 0 + + GPROF *ft-gprof-plugin* The gprof filetype plugin defines a mapping <C-]> to jump from a function @@ -602,6 +625,12 @@ The mapping can be disabled with: > let g:no_gprof_maps = 1 +HARE *ft-hare* + +Since the text for this plugin is rather long it has been put in a separate +file: |ft_hare.txt|. + + JAVA *ft-java-plugin* Whenever the variable "g:ftplugin_java_source_path" is defined and its value @@ -632,6 +661,27 @@ Remember to manually trigger the |FileType| event from a buffer with a Java file loaded in it each time after assigning a new value to the variable: > doautocmd FileType < +Markdown documentation comments may contain common runs of vertical leading +whitespace following the comment marks (`///`) for aesthetic reasons; however, +some horizontal runs of leading whitespace are significant in Markdown because +they denote code blocks etc. For convenience, a 'formatexpr' function is +provided for the |gq| operator. As long as neither "g:java_ignore_javadoc" +nor "g:java_ignore_markdown" is defined, the reformatting of Markdown comments +can be enabled on demand with: > + setlocal formatexpr=g:javaformat#RemoveCommonMarkdownWhitespace() +< +Or for Vim versions less than `7.4.265`, with: > + setlocal formatexpr=javaformat#RemoveCommonMarkdownWhitespace() +< +This function accepts a range of lines, removes a common run of vertical +leading whitespace, and rewrites the lines of the range. Depending on the +author's layout style and the comment contents, which lines to select for +reformatting can vary from the whole comment to only some portion of it. +To enable the recognition of Markdown comments each time after removing +"g:java_ignore_markdown" or "g:java_ignore_javadoc", remember to manually +re-source "javaformat.vim" for Vim versions greater than `8.2.1397`: > + runtime autoload/javaformat.vim +< MAIL *ft-mail-plugin* @@ -984,6 +1034,10 @@ You can change the default by defining the variable g:tex_flavor to the format let g:tex_flavor = "latex" Currently no other formats are recognized. +TYPST *ft-typst-plugin* + + *g:typst_conceal* +When |TRUE| the Typst filetype plugin will set the 'conceallevel' option to 2. VIM *ft-vim-plugin* diff --git a/runtime/doc/fold.txt b/runtime/doc/fold.txt index 8f7393f5e3..b844e0ed85 100644 --- a/runtime/doc/fold.txt +++ b/runtime/doc/fold.txt @@ -69,8 +69,6 @@ method. The value of the 'foldexpr' option is evaluated to get the foldlevel of a line. Examples: This will create a fold for all consecutive lines that start with a tab: > :set foldexpr=getline(v:lnum)[0]==\"\\t\" -This will call a function to compute the fold level: > - :set foldexpr=MyFoldLevel(v:lnum) This will make a fold out of paragraphs separated by blank lines: > :set foldexpr=getline(v:lnum)=~'^\\s*$'&&getline(v:lnum+1)=~'\\S'?'<1':1 This does the same: > @@ -79,6 +77,10 @@ This does the same: > Note that backslashes must be used to escape characters that ":set" handles differently (space, backslash, double quote, etc., see |option-backslash|). +The most efficient is to call a function without arguments: > + :set foldexpr=MyFoldLevel() +The function must use v:lnum. See |expr-option-function|. + These are the conditions with which the expression is evaluated: - The current buffer and window are set for the line. - The variable "v:lnum" is set to the line number. diff --git a/runtime/doc/ft_ada.txt b/runtime/doc/ft_ada.txt index a9302cde97..337a4cba6a 100644 --- a/runtime/doc/ft_ada.txt +++ b/runtime/doc/ft_ada.txt @@ -48,14 +48,12 @@ ctermfg=White often shows well). There are several options you can select in this Ada mode. See |ft-ada-options| for a complete list. -To enable them, assign a value to the option. For example, to turn one on: - > - > let g:ada_standard_types = 1 - -To disable them use ":unlet". Example: -> - > unlet g:ada_standard_types - +To enable them, assign a value to the option. For example, to turn one on: > + let g:ada_standard_types = 1 +< +To disable them use ":unlet". Example: > + unlet g:ada_standard_types +< You can just use ":" and type these into the command line to set these temporarily before loading an Ada file. You can make these option settings permanent by adding the "let" command(s), without a colon, to your |init.vim| @@ -158,10 +156,9 @@ several versions available which differ in the licence terms used. The GNAT compiler plug-in will perform a compile on pressing <F7> and then immediately shows the result. You can set the project file to be used by -setting: - > - > call g:gnat.Set_Project_File ('my_project.gpr') - +setting: > + call g:gnat.Set_Project_File ('my_project.gpr') +< Setting a project file will also create a Vim session (|views-sessions|) so - like with the GPS - opened files, window positions etc. will be remembered separately for all projects. diff --git a/runtime/doc/ft_hare.txt b/runtime/doc/ft_hare.txt new file mode 100644 index 0000000000..937c5e0961 --- /dev/null +++ b/runtime/doc/ft_hare.txt @@ -0,0 +1,77 @@ +*ft_hare.txt* Support for the Hare programming language + +============================================================================== +CONTENTS *hare* + +1. Introduction |hare-intro| +2. Filetype plugin |hare-plugin| +3. Settings |hare-settings| + +============================================================================== +INTRODUCTION *hare-intro* + +This plugin provides syntax highlighting, indentation, and other functionality +for the Hare programming language. Support is also provided for README files +inside Hare modules, but this must be enabled by setting |g:filetype_haredoc|. + +============================================================================== +FILETYPE PLUGIN *hare-plugin* + +This plugin automatically sets the value of 'path' to include the contents of +the HAREPATH environment variable, allowing commands such as |gf| to directly +open standard library or third-party modules. If HAREPATH is not set, it +defaults to the recommended paths for most Unix-like filesystems, namely +/usr/src/hare/stdlib and /usr/src/hare/third-party. + +============================================================================== +SETTINGS *hare-settings* + +This plugin provides a small number of variables that you can define in your +vimrc to configure its behavior. + + *g:filetype_haredoc* +This plugin is able to automatically detect Hare modules and set the "haredoc" +filetype for any README files. As the recursive directory search used as a +heuristic has a minor performance impact, this feature is disabled by default +and must be specifically opted into: > + let g:filetype_haredoc = 1 +< +See |g:haredoc_search_depth| for ways to tweak the searching behavior. + + *g:hare_recommended_style* +The following options are set by default, in accordance with the official Hare +style guide: > + setlocal noexpandtab + setlocal shiftwidth=0 + setlocal softtabstop=0 + setlocal tabstop=8 + setlocal textwidth=80 +< +To disable this behavior: > + let g:hare_recommended_style = 0 +< + *g:hare_space_error* +By default, trailing whitespace and tabs preceded by space characters are +highlighted as errors. This is automatically turned off when in insert mode. +To disable this highlighting completely: > + let g:hare_space_error = 0 +< + *g:haredoc_search_depth* +By default, when |g:filetype_haredoc| is enabled, only the current directory +and its immediate subdirectories are searched for Hare files. The maximum +search depth may be adjusted with: > + let g:haredoc_search_depth = 2 +< + Value Effect~ + 0 Only search the current directory. + 1 Search the current directory and immediate + subdirectories. + 2 Search the current directory and two levels of + subdirectories. + +The maximum search depth can be set to any integer, but using values higher +than 2 is not recommended, and will likely provide no tangible benefit in most +situations. + +============================================================================== + vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/runtime/doc/ft_sql.txt b/runtime/doc/ft_sql.txt index 241fa4bd74..1dbac66db0 100644 --- a/runtime/doc/ft_sql.txt +++ b/runtime/doc/ft_sql.txt @@ -293,7 +293,7 @@ loaded by Vim: > ftplugin/sql.vim syntax/sqlinformix.vim indent/sql.vim -> +< Notice indent/sqlinformix.sql was not loaded. There is no indent file for Informix, Vim loads the default files if the specified files does not exist. @@ -349,7 +349,7 @@ The defaults static maps are: > The use of "<C-C>" can be user chosen by using the following in your |init.vim| as it may not work properly on all platforms: > let g:ftplugin_sql_omni_key = '<C-C>' -> +< The static maps (which are based on the syntax highlight groups) follow this format: > imap <buffer> <C-C>k <C-\><C-O>:call sqlcomplete#Map('sqlKeyword')<CR><C-X><C-O> @@ -664,7 +664,7 @@ your |init.vim|: > filetype is changed temporarily to SQL, the sqlcompletion plugin will cache the syntax groups listed in the List specified in this option. -> + ------------------------------------------------------------------------------ 4.5 SQL Maps *sql-completion-maps* diff --git a/runtime/doc/gui.txt b/runtime/doc/gui.txt index a64d722177..9ab5bf4e1e 100644 --- a/runtime/doc/gui.txt +++ b/runtime/doc/gui.txt @@ -6,14 +6,38 @@ Nvim Graphical User Interface *gui* *GUI* +Any client that supports the Nvim |ui-protocol| can be used as a UI for Nvim. +And multiple UIs can connect to the same Nvim instance! The terms "UI" and +"GUI" are often used interchangeably because all Nvim UI clients have the same +potential capabilities; the "TUI" refers to a UI client that outputs to your +terminal, whereas a "GUI" outputs directly to the OS graphics system. + +Except where noted, this document describes UI capabilities available to both +TUI and GUI (assuming the UI supports the given feature). See |TUI| for notes +specific to the terminal UI. Help tags with the "gui-" prefix refer to UI +features, whereas help tags with the "ui-" prefix refer to the |ui-protocol|. + +Nvim provides a default, builtin UI (the |TUI|), but there are many other +(third-party) GUIs that you can use instead: + +- Firenvim (Nvim in your web browser!) https://github.com/glacambre/firenvim +- vscode-neovim (Nvim in VSCode!) https://github.com/vscode-neovim/vscode-neovim +- Neovide https://neovide.dev/ +- Goneovim https://github.com/akiyosi/goneovim +- Nvy https://github.com/RMichelsen/Nvy +- Neovim-Qt (Qt5) https://github.com/equalsraf/neovim-qt +- VimR (macOS) https://github.com/qvacua/vimr +- Others https://github.com/neovim/neovim/wiki/Related-projects#gui + Type |gO| to see the table of contents. ============================================================================== -Starting the GUI *gui-start* *E229* *E233* +Starting the GUI *gui-config* *gui-start* *ginit.vim* *gui-init* *gvimrc* *$MYGVIMRC* For GUI-specific configuration Nvim provides the |UIEnter| event. This -happens after other |initialization|s, like reading your vimrc file. +happens after other |initialization|s, or whenever a UI attaches (multiple UIs +can connect to any Nvim instance). Example: this sets "g:gui" to the value of the UI's "rgb" field: > :autocmd UIEnter * let g:gui = filter(nvim_list_uis(),{k,v-> v.chan==v:event.chan})[0].rgb @@ -221,7 +245,7 @@ is right aligned, and the "O" is underlined, to indicate it is the shortcut. *:am* *:amenu* *:an* *:anoremenu* The ":amenu" command can be used to define menu entries for all modes at once, -expect for Terminal mode. To make the command work correctly, a character is +except for Terminal mode. To make the command work correctly, a character is automatically inserted for some modes: mode inserted appended ~ Normal nothing nothing @@ -444,6 +468,10 @@ when the right mouse button is pressed, if 'mousemodel' is set to popup or popup_setpos. The default "PopUp" menu is: >vim + anoremenu PopUp.Go\ to\ definition <Cmd>lua vim.lsp.buf.definition()<CR> + amenu PopUp.Open\ in\ web\ browser gx + anoremenu PopUp.Inspect <Cmd>Inspect<CR> + anoremenu PopUp.-1- <Nop> vnoremenu PopUp.Cut "+x vnoremenu PopUp.Copy "+y anoremenu PopUp.Paste "+gP @@ -452,8 +480,7 @@ The default "PopUp" menu is: >vim nnoremenu PopUp.Select\ All ggVG vnoremenu PopUp.Select\ All gg0oG$ inoremenu PopUp.Select\ All <C-Home><C-O>VG - anoremenu PopUp.Inspect <Cmd>Inspect<CR> - anoremenu PopUp.-1- <Nop> + anoremenu PopUp.-2- <Nop> anoremenu PopUp.How-to\ disable\ mouse <Cmd>help disable-mouse<CR> < @@ -548,7 +575,7 @@ name and all existing submenus below it are affected. Examples for Menus *menu-examples* -Here is an example on how to add menu items with menu's! You can add a menu +Here is an example on how to add menu items with menus! You can add a menu item for the keyword under the cursor. The register "z" is used. > :nmenu Words.Add\ Var wb"zye:menu! Words.<C-R>z <C-R>z<CR> @@ -612,9 +639,6 @@ a menu item - you don't need to do a :tunmenu as well. You can cause a menu to popup at the cursor. This behaves similarly to the PopUp menus except that any menu tree can be popped up. -This command is for backwards compatibility, using it is discouraged, because -it behaves in a strange way. - *:popup* *:popu* :popu[p] {name} Popup the menu {name}. The menu named must have at least one subentry, but need not diff --git a/runtime/doc/health.txt b/runtime/doc/health.txt index e879f11351..cb70961b55 100644 --- a/runtime/doc/health.txt +++ b/runtime/doc/health.txt @@ -7,10 +7,10 @@ Type |gO| to see the table of contents. ============================================================================== -Checkhealth *health* +Checkhealth *vim.health* *health* -health.vim is a minimal framework to help users troubleshoot configuration and +vim.health is a minimal framework to help users troubleshoot configuration and any other environment conditions that a plugin might care about. Nvim ships with healthchecks for configuration, performance, python support, ruby support, clipboard support, and more. @@ -49,7 +49,7 @@ Commands *health-commands* :checkhealth vim* < -Create a healthcheck *health-dev* *vim.health* +Create a healthcheck *health-dev* Healthchecks are functions that check the user environment, configuration, or any other prerequisites that a plugin cares about. Nvim ships with diff --git a/runtime/doc/help.txt b/runtime/doc/help.txt index 43f80101ed..fd8bfd644f 100644 --- a/runtime/doc/help.txt +++ b/runtime/doc/help.txt @@ -127,6 +127,7 @@ PROGRAMMING LANGUAGE SUPPORT |filetype| Settings for specific types of files |quickfix| Commands for a quick edit-compile-fix cycle |ft_ada.txt| Ada filetype plugin +|ft_hare.txt| Filetype plugin for Hare |ft_ps1.txt| PowerShell filetype plugin |ft_raku.txt| Raku filetype plugin |ft_rust.txt| Rust filetype plugin @@ -168,6 +169,7 @@ VERSIONS DEVELOPING NVIM |dev| Development of Nvim +|dev-arch| Internal architecture, modules, data structures |dev-style| Development style guidelines |dev-theme| Design guidelines (colorschemes etc.) |dev-tools| Tools and techniques for developing Nvim @@ -187,7 +189,7 @@ Local additions ~ *local-additions* ------------------------------------------------------------------------------ -*bars* Bars example +Bars example *bars* Now that you've jumped here with CTRL-] or a double mouse click, you can use CTRL-T, CTRL-O, g<RightMouse>, or <C-RightMouse> to go back to where you were. @@ -199,5 +201,5 @@ You can use CTRL-] on any word (even if it is not within "|") and Nvim will try to find help for it. Especially for options in single quotes, e.g. 'hlsearch'. ------------------------------------------------------------------------------- + vim:tw=78:isk=!-~,^*,^\|,^\":ts=8:noet:ft=help:norl: diff --git a/runtime/doc/indent.txt b/runtime/doc/indent.txt index a890d531ac..f97ae24068 100644 --- a/runtime/doc/indent.txt +++ b/runtime/doc/indent.txt @@ -116,7 +116,7 @@ If you really want to reindent when you type 'o', 'O', 'e', '0', '<', '>', "<!>", respectively, for those keys. For an emacs-style indent mode where lines aren't indented every time you -press <Enter> but only if you press <Tab>, I suggest: +press <Enter> but only if you press <Tab>, I suggest: > :set cinkeys=0{,0},:,0#,!<Tab>,!^F You might also want to switch off 'autoindent' then. diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index 79f10b33f1..9ee75ea950 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -196,10 +196,12 @@ tag char note action in Normal mode ~ |<Tab>| <Tab> 1 go to N newer entry in jump list |CTRL-I| CTRL-I 1 same as <Tab> |<NL>| <NL> 1 same as "j" +|<S-NL>| <S-NL> 1 same as CTRL-F |CTRL-J| CTRL-J 1 same as "j" CTRL-K not used |CTRL-L| CTRL-L redraw screen |<CR>| <CR> 1 cursor to the first CHAR N lines lower +|<S-CR>| <S-CR> 1 same as CTRL-F |CTRL-M| CTRL-M 1 same as <CR> |CTRL-N| CTRL-N 1 same as "j" |CTRL-O| CTRL-O 1 go to N older entry in jump list @@ -272,9 +274,11 @@ tag char note action in Normal mode ~ |star| * 1 search forward for the Nth occurrence of the ident under the cursor |+| + 1 same as <CR> +|<S-Plus>| <S-+> 1 same as CTRL-F |,| , 1 repeat latest f, t, F or T in opposite direction N times |-| - 1 cursor to the first CHAR N lines higher +|<S-Minus>| <S--> 1 same as CTRL-B |.| . 2 repeat last change with count replaced with N |/| /{pattern}<CR> 1 search forward for the Nth occurrence of @@ -366,7 +370,7 @@ tag char note action in Normal mode ~ or start of putted text |`]| `] 1 cursor to the end of last operated text or end of putted text -|``| `` 1 cursor to the position before latest jump +|``| "``" 1 cursor to the position before latest jump |`{| `{ 1 cursor to the start of the current paragraph |`}| `} 1 cursor to the end of the current paragraph |a| a 2 append text after the cursor N times @@ -397,7 +401,7 @@ tag char note action in Normal mode ~ |q| q{0-9a-zA-Z"} record typed characters into named register {0-9a-zA-Z"} (uppercase to append) |q| q (while recording) stops recording -|Q| Q replay last recorded macro +|Q| Q 2 replay last recorded register |q:| q: edit : command-line in command-line window |q/| q/ edit / command-line in command-line window |q?| q? edit ? command-line in command-line window @@ -736,7 +740,7 @@ tag char note action in Normal mode ~ search pattern and Visually select it |gP| ["x]gP 2 put the text [from register x] before the cursor N times, leave the cursor after it -|gQ| gQ switch to "Ex" mode with Vim editing +|gQ| gQ switch to "Ex" mode with Vim editing |gR| gR 2 enter Virtual Replace mode |gT| gT go to the previous tab page |gU| gU{motion} 2 make Nmove text uppercase @@ -923,7 +927,6 @@ tag command note action in Visual mode ~ |v_O| O move horizontally to other corner of area |v_P| P replace highlighted area with register contents; registers are unchanged - Q does not start Ex mode |v_R| R 2 delete the highlighted lines and start insert |v_S| S 2 delete the highlighted lines and start @@ -1136,7 +1139,7 @@ tag command action ~ |:!!| :!! repeat last ":!" command |:#| :# same as ":number" |:&| :& repeat last ":substitute" -|:star| :* use the last Visual area, like :'<,'> +|:star| :* use the last Visual area, like ":'<,'>" |:<| :< shift lines one 'shiftwidth' left |:=| := print the last line number |:>| :> shift lines one 'shiftwidth' right diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt index 91b0d41f1c..d7cbb7c78e 100644 --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -1177,6 +1177,18 @@ items: user_data custom data which is associated with the item and available in |v:completed_item|; it can be any type; defaults to an empty string + hl_group an additional highlight group whose attributes are + combined with |hl-PmenuSel| and |hl-Pmenu| or + |hl-PmenuMatchSel| and |hl-PmenuMatch| highlight + attributes in the popup menu to apply cterm and gui + properties (with higher priority) like strikethrough + to the completion items + kind_hlgroup an additional highlight group specifically for setting + the highlight attributes of the completion kind. When + this field is present, it will override the + |hl-PmenuKind| highlight group, allowing for the + customization of ctermfg and guifg properties for the + completion kind All of these except "icase", "equal", "dup" and "empty" must be a string. If an item does not meet these requirements then an error message is given and @@ -1927,11 +1939,16 @@ These two commands will keep on asking for lines, until you type a line containing only a ".". Watch out for lines starting with a backslash, see |line-continuation|. -When in Ex mode (see |-e|) a backslash at the end of the line can be used to -insert a NUL character. To be able to have a line ending in a backslash use -two backslashes. This means that the number of backslashes is halved, but -only at the end of the line. - +Text typed after a "|" command separator is used first. So the following +command in ex mode: > + :a|one + two + . + :visual +appends the following text, after the cursor line: > + one + two +< NOTE: These commands cannot be used with |:global| or |:vglobal|. ":append" and ":insert" don't work properly in between ":if" and ":endif", ":for" and ":endfor", ":while" and ":endwhile". diff --git a/runtime/doc/intro.txt b/runtime/doc/intro.txt index 4c757cc1f6..41846f8eed 100644 --- a/runtime/doc/intro.txt +++ b/runtime/doc/intro.txt @@ -688,7 +688,7 @@ The current mode is "-- INSERT --" or "-- REPLACE --", see |'showmode'|. The command characters are those that you typed but were not used yet. If you have a slow terminal you can switch off the status messages to speed -up editing: +up editing: > :set nosc noru nosm If there is an error, an error message will be shown for at least one second diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index 50fffca497..419f583c36 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -34,16 +34,16 @@ Follow these steps to get LSP features: vim.api.nvim_create_autocmd('FileType', { -- This handler will fire when the buffer's 'filetype' is "python" pattern = 'python', - callback = function(ev) + callback = function(args) vim.lsp.start({ name = 'my-server-name', cmd = {'name-of-language-server-executable', '--option', 'arg1', 'arg2'}, -- Set the "root directory" to the parent directory of the file in the - -- current buffer (`ev.buf`) that contains either a "setup.py" or a + -- current buffer (`args.buf`) that contains either a "setup.py" or a -- "pyproject.toml" file. Files that share a root directory will reuse -- the connection to the same LSP server. - root_dir = vim.fs.root(ev.buf, {'setup.py', 'pyproject.toml'}), + root_dir = vim.fs.root(args.buf, {'setup.py', 'pyproject.toml'}), }) end, }) @@ -86,18 +86,21 @@ To override or delete any of the above defaults, set or unset the options on |LspAttach|: >lua vim.api.nvim_create_autocmd('LspAttach', { - callback = function(ev) - vim.bo[ev.buf].formatexpr = nil - vim.bo[ev.buf].omnifunc = nil - vim.keymap.del('n', 'K', { buffer = ev.buf }) + callback = function(args) + -- Unset 'formatexpr' + vim.bo[args.buf].formatexpr = nil + -- Unset 'omnifunc' + vim.bo[args.buf].omnifunc = nil + -- Unmap K + vim.keymap.del('n', 'K', { buffer = args.buf }) end, }) < *lsp-config* -To use other LSP features, set keymaps on |LspAttach|. Not all language -servers provide the same capabilities. To ensure you only set keymaps if the -language server supports a feature, guard keymaps behind capability checks. -Example: >lua +To use other LSP features, set keymaps and other buffer options on +|LspAttach|. Not all language servers provide the same capabilities. Use +capability checks to ensure you only use features supported by the language +server. Example: >lua vim.api.nvim_create_autocmd('LspAttach', { callback = function(args) @@ -105,6 +108,21 @@ Example: >lua if client.supports_method('textDocument/implementation') then -- Create a keymap for vim.lsp.buf.implementation end + + if client.supports_method('textDocument/completion') then + -- Enable auto-completion + vim.lsp.completion.enable(true, client.id, args.buf, {autotrigger = true}) + end + + if client.supports_method('textDocument/formatting') then + -- Format the current buffer on save + vim.api.nvim_create_autocmd('BufWritePre', { + buffer = args.buf, + callback = function() + vim.lsp.buf.format({bufnr = args.buf, id = client.id}) + end, + }) + end end, }) < @@ -191,6 +209,7 @@ won't run if your server doesn't support them. - textDocument/prepareTypeHierarchy - textDocument/publishDiagnostics - textDocument/rangeFormatting +- textDocument/rangesFormatting - textDocument/references - textDocument/rename - textDocument/semanticTokens/full @@ -220,26 +239,26 @@ Each response handler has this signature: > function(err, result, ctx, config) < Parameters: ~ - - {err} (table|nil) Error info dict, or `nil` if the request - completed. - - {result} (Result | Params | nil) `result` key of the |lsp-response| or - `nil` if the request failed. - - {ctx} (table) Table of calling state associated with the - handler, with these keys: - - {method} (string) |lsp-method| name. - - {client_id} (number) |vim.lsp.Client| identifier. - - {bufnr} (Buffer) Buffer handle. - - {params} (table|nil) Request parameters table. - - {version} (number) Document version at time of - request. Handlers can compare this to the - current document version to check if the - response is "stale". See also |b:changedtick|. - - {config} (table) Handler-defined configuration table, which allows - users to customize handler behavior. - For an example, see: - |vim.lsp.diagnostic.on_publish_diagnostics()| - To configure a particular |lsp-handler|, see: - |lsp-handler-configuration| + • {err} (`table|nil`) Error info dict, or `nil` if the request + completed. + • {result} (`Result|Params|nil`) `result` key of the |lsp-response| or + `nil` if the request failed. + • {ctx} (`table`) Table of calling state associated with the + handler, with these keys: + • {method} (`string`) |lsp-method| name. + • {client_id} (`number`) |vim.lsp.Client| identifier. + • {bufnr} (`Buffer`) Buffer handle. + • {params} (`table|nil`) Request parameters table. + • {version} (`number`) Document version at time of + request. Handlers can compare this to the + current document version to check if the + response is "stale". See also |b:changedtick|. + • {config} (`table`) Handler-defined configuration table, which allows + users to customize handler behavior. + For an example, see: + |vim.lsp.diagnostic.on_publish_diagnostics()| + To configure a particular |lsp-handler|, see: + |lsp-handler-configuration| Returns: ~ Two values `result, err` where `err` is shaped like an RPC error: > @@ -302,7 +321,7 @@ To configure the behavior of a builtin |lsp-handler|, the convenient method } < Some handlers do not have an explicitly named handler function (such as - ||vim.lsp.diagnostic.on_publish_diagnostics()|). To override these, first + |vim.lsp.diagnostic.on_publish_diagnostics()|). To override these, first create a reference to the existing handler: >lua local on_references = vim.lsp.handlers["textDocument/references"] @@ -508,32 +527,25 @@ EVENTS *lsp-events* LspAttach *LspAttach* After an LSP client attaches to a buffer. The |autocmd-pattern| is the name of the buffer. When used from Lua, the client ID is passed to the - callback in the "data" table. Example: >lua - - vim.api.nvim_create_autocmd("LspAttach", { - callback = function(args) - local bufnr = args.buf - local client = vim.lsp.get_client_by_id(args.data.client_id) - if client.server_capabilities.completionProvider then - vim.bo[bufnr].omnifunc = "v:lua.vim.lsp.omnifunc" - end - if client.server_capabilities.definitionProvider then - vim.bo[bufnr].tagfunc = "v:lua.vim.lsp.tagfunc" - end - end, - }) -< + callback in the "data" table. See |lsp-config| for an example. LspDetach *LspDetach* Just before an LSP client detaches from a buffer. The |autocmd-pattern| is the name of the buffer. When used from Lua, the client ID is passed to the callback in the "data" table. Example: >lua - vim.api.nvim_create_autocmd("LspDetach", { + vim.api.nvim_create_autocmd('LspDetach', { callback = function(args) + -- Get the detaching client local client = vim.lsp.get_client_by_id(args.data.client_id) - -- Do something with the client - vim.cmd("setlocal tagfunc< omnifunc<") + + -- Remove the autocommand to format the buffer on save, if it exists + if client.supports_method('textDocument/formatting') then + vim.api.nvim_clear_autocmds({ + event = 'BufWritePre', + buffer = args.buf, + }) + end end, }) < @@ -750,7 +762,7 @@ formatexpr({opts}) *vim.lsp.formatexpr()* function. Currently only supports a single client. This can be set via - `setlocal formatexpr=v:lua.vim.lsp.formatexpr()` but will typically or in + `setlocal formatexpr=v:lua.vim.lsp.formatexpr()` or (more typically) in `on_attach` via `vim.bo[bufnr].formatexpr = 'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})'`. @@ -874,13 +886,13 @@ start({config}, {opts}) *vim.lsp.start()* • {config} (`vim.lsp.ClientConfig`) Configuration for the server. See |vim.lsp.ClientConfig|. • {opts} (`table?`) Optional keyword arguments - • {reuse_client} + • {reuse_client}? (`fun(client: vim.lsp.Client, config: vim.lsp.ClientConfig): boolean`) Predicate used to decide if a client should be re-used. Used on all running clients. The default implementation re-uses a client if name and root_dir matches. - • {bufnr} (`integer`) Buffer handle to attach to if starting - or re-using a client (0 for current). + • {bufnr}? (`integer`) Buffer handle to attach to if + starting or re-using a client (0 for current). • {silent}? (`boolean`) Suppress error reporting if the LSP server fails to start (default false). @@ -996,7 +1008,7 @@ Lua module: vim.lsp.client *lsp-client* if the client supports workspace folders. It can be `null` if the client supports workspace folders but none are configured. - • {root_dir} (`string`) + • {root_dir} (`string?`) • {attached_buffers} (`table<integer,true>`) • {commands} (`table<string,fun(command: lsp.Command, ctx: table)>`) Table of command name to function which is @@ -1043,7 +1055,7 @@ Lua module: vim.lsp.client *lsp-client* `client.cancel_request(request_id)` to cancel the request. • {request_sync} (`fun(method: string, params: table?, timeout_ms: integer?, bufnr: integer): {err: lsp.ResponseError?, result:any}?, string?`) - err # a dictionary, where + err # a dict • {notify} (`fun(method: string, params: table?): boolean`) Sends a notification to an LSP server. Returns: a boolean to indicate if the @@ -1371,15 +1383,22 @@ format({opts}) *vim.lsp.buf.format()* (client.id) matching this field. • {name}? (`string`) Restrict formatting to the client with name (client.name) matching this field. - • {range}? (`{start:integer[],end:integer[]}`, default: - current selection in visual mode, `nil` in other modes, - formatting the full buffer) Range to format. Table must - contain `start` and `end` keys with {row,col} tuples using - (1,0) indexing. + • {range}? + (`{start:[integer,integer],end:[integer, integer]}|{start:[integer,integer],end:[integer,integer]}[]`, + default: current selection in visual mode, `nil` in other + modes, formatting the full buffer) Range to format. Table + must contain `start` and `end` keys with {row,col} tuples + using (1,0) indexing. Can also be a list of tables that + contain `start` and `end` keys as described above, in which + case `textDocument/rangesFormatting` support is required. hover() *vim.lsp.buf.hover()* Displays hover information about the symbol under the cursor in a floating - window. Calling the function twice will jump into the floating window. + window. The window will be dismissed on cursor move. Calling the function + twice will jump into the floating window (thus by default, "KK" will open + the hover window and focus it). In the floating window, all commands and + mappings are available as usual, except that "q" dismisses the window. You + can scroll the contents the same as you would any other buffer. implementation({opts}) *vim.lsp.buf.implementation()* Lists all the implementations for the symbol under the cursor in the @@ -1468,6 +1487,15 @@ workspace_symbol({query}, {opts}) *vim.lsp.buf.workspace_symbol()* ============================================================================== Lua module: vim.lsp.diagnostic *lsp-diagnostic* +from({diagnostics}) *vim.lsp.diagnostic.from()* + Converts the input `vim.Diagnostic`s to LSP diagnostics. + + Parameters: ~ + • {diagnostics} (`vim.Diagnostic[]`) + + Return: ~ + (`lsp.Diagnostic[]`) + *vim.lsp.diagnostic.get_namespace()* get_namespace({client_id}, {is_pull}) Get the diagnostic namespace associated with an LSP client @@ -1605,6 +1633,34 @@ save({lenses}, {bufnr}, {client_id}) *vim.lsp.codelens.save()* ============================================================================== +Lua module: vim.lsp.completion *lsp-completion* + +*vim.lsp.completion.BufferOpts* + + Fields: ~ + • {autotrigger}? (`boolean`) Whether to trigger completion + automatically. Default: false + • {convert}? (`fun(item: lsp.CompletionItem): table`) Transforms an + LSP CompletionItem to |complete-items|. + + + *vim.lsp.completion.enable()* +enable({enable}, {client_id}, {bufnr}, {opts}) + Enables or disables completions from the given language client in the + given buffer. + + Parameters: ~ + • {enable} (`boolean`) True to enable, false to disable + • {client_id} (`integer`) Client ID + • {bufnr} (`integer`) Buffer handle, or 0 for the current buffer + • {opts} (`vim.lsp.completion.BufferOpts?`) See + |vim.lsp.completion.BufferOpts|. + +trigger() *vim.lsp.completion.trigger()* + Trigger LSP completion in the current buffer. + + +============================================================================== Lua module: vim.lsp.inlay_hint *lsp-inlay_hint* enable({enable}, {filter}) *vim.lsp.inlay_hint.enable()* @@ -1614,6 +1670,9 @@ enable({enable}, {filter}) *vim.lsp.inlay_hint.enable()* vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) < + Attributes: ~ + Since: 0.10.0 + Parameters: ~ • {enable} (`boolean?`) true/nil to enable, false to disable • {filter} (`table?`) Optional filters |kwargs|, or `nil` for all. @@ -1638,6 +1697,9 @@ get({filter}) *vim.lsp.inlay_hint.get()* }) < + Attributes: ~ + Since: 0.10.0 + Parameters: ~ • {filter} (`table?`) Optional filters |kwargs|: • {bufnr} (`integer?`) @@ -1652,8 +1714,11 @@ get({filter}) *vim.lsp.inlay_hint.get()* is_enabled({filter}) *vim.lsp.inlay_hint.is_enabled()* Query whether inlay hint is enabled in the {filter}ed scope + Attributes: ~ + Since: 0.10.0 + Parameters: ~ - • {filter} (`table`) Optional filters |kwargs|, or `nil` for all. + • {filter} (`table?`) Optional filters |kwargs|, or `nil` for all. • {bufnr} (`integer?`) Buffer number, or 0 for current buffer, or nil for all. @@ -1806,8 +1871,8 @@ apply_text_document_edit({text_document_edit}, {index}, {offset_encoding}) document. Parameters: ~ - • {text_document_edit} (`table`) a `TextDocumentEdit` object - • {index} (`integer`) Optional index of the edit, if from + • {text_document_edit} (`lsp.TextDocumentEdit`) + • {index} (`integer?`) Optional index of the edit, if from a list of edits (or nil, if not from a list) • {offset_encoding} (`string?`) @@ -1819,7 +1884,7 @@ apply_text_edits({text_edits}, {bufnr}, {offset_encoding}) Applies a list of text edits to a buffer. Parameters: ~ - • {text_edits} (`table`) list of `TextEdit` objects + • {text_edits} (`lsp.TextEdit[]`) • {bufnr} (`integer`) Buffer id • {offset_encoding} (`string`) utf-8|utf-16|utf-32 @@ -1831,7 +1896,7 @@ apply_workspace_edit({workspace_edit}, {offset_encoding}) Applies a `WorkspaceEdit`. Parameters: ~ - • {workspace_edit} (`table`) `WorkspaceEdit` + • {workspace_edit} (`lsp.WorkspaceEdit`) • {offset_encoding} (`string`) utf-8|utf-16|utf-32 (required) See also: ~ @@ -1849,8 +1914,7 @@ buf_highlight_references({bufnr}, {references}, {offset_encoding}) Parameters: ~ • {bufnr} (`integer`) Buffer id - • {references} (`table`) List of `DocumentHighlight` objects to - highlight + • {references} (`lsp.DocumentHighlight[]`) objects to highlight • {offset_encoding} (`string`) One of "utf-8", "utf-16", "utf-32". See also: ~ @@ -1884,8 +1948,8 @@ convert_input_to_markdown_lines({input}, {contents}) Parameters: ~ • {input} (`lsp.MarkedString|lsp.MarkedString[]|lsp.MarkupContent`) - • {contents} (`table?`) List of strings to extend with converted lines. - Defaults to {}. + • {contents} (`string[]?`) List of strings to extend with converted + lines. Defaults to {}. Return: ~ (`string[]`) extended with lines of converted markdown. @@ -1898,15 +1962,16 @@ convert_signature_help_to_markdown_lines({signature_help}, {ft}, {triggers}) Converts `textDocument/signatureHelp` response to markdown lines. Parameters: ~ - • {signature_help} (`table`) Response of `textDocument/SignatureHelp` + • {signature_help} (`lsp.SignatureHelp`) Response of + `textDocument/SignatureHelp` • {ft} (`string?`) filetype that will be use as the `lang` for the label markdown code block • {triggers} (`table?`) list of trigger characters from the lsp server. used to better determine parameter offsets Return (multiple): ~ - (`table?`) table list of lines of converted markdown. - (`table?`) table of active hl + (`string[]?`) table list of lines of converted markdown. + (`number[]?`) table of active hl See also: ~ • https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_signatureHelp @@ -1928,7 +1993,7 @@ jump_to_location({location}, {offset_encoding}, {reuse_win}) Jumps to a location. Parameters: ~ - • {location} (`table`) (`Location`|`LocationLink`) + • {location} (`lsp.Location|lsp.LocationLink`) • {offset_encoding} (`string?`) utf-8|utf-16|utf-32 • {reuse_win} (`boolean?`) Jump to existing window if buffer is already open. @@ -1957,7 +2022,9 @@ locations_to_items({locations}, {offset_encoding}) (`table[]`) A list of objects with the following fields: • {filename} (`string`) • {lnum} (`integer`) 1-indexed line number + • {end_lnum} (`integer`) 1-indexed end line number • {col} (`integer`) 1-indexed column + • {end_col} (`integer`) 1-indexed end column • {text} (`string`) • {user_data} (`lsp.Location|lsp.LocationLink`) @@ -1993,7 +2060,8 @@ make_formatting_params({options}) cursor position. Parameters: ~ - • {options} (`table?`) with valid `FormattingOptions` entries + • {options} (`lsp.FormattingOptions?`) with valid `FormattingOptions` + entries Return: ~ (`lsp.DocumentFormattingParams`) object @@ -2033,7 +2101,7 @@ make_position_params({window}, {offset_encoding}) `window` Return: ~ - (`table`) `TextDocumentPositionParams` object + (`lsp.TextDocumentPositionParams`) See also: ~ • https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentPositionParams @@ -2064,7 +2132,7 @@ make_text_document_params({bufnr}) • {bufnr} (`integer?`) Buffer handle, defaults to current Return: ~ - (`table`) `TextDocumentIdentifier` + (`lsp.TextDocumentIdentifier`) See also: ~ • https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentIdentifier @@ -2074,8 +2142,11 @@ make_workspace_params({added}, {removed}) Create the workspace params Parameters: ~ - • {added} (`table`) - • {removed} (`table`) + • {added} (`lsp.WorkspaceFolder[]`) + • {removed} (`lsp.WorkspaceFolder[]`) + + Return: ~ + (`lsp.WorkspaceFoldersChangeEvent`) *vim.lsp.util.open_floating_preview()* open_floating_preview({contents}, {syntax}, {opts}) @@ -2119,7 +2190,7 @@ preview_location({location}, {opts}) *vim.lsp.util.preview_location()* definition) Parameters: ~ - • {location} (`table`) a single `Location` or `LocationLink` + • {location} (`lsp.Location|lsp.LocationLink`) • {opts} (`table`) Return (multiple): ~ @@ -2149,7 +2220,7 @@ show_document({location}, {offset_encoding}, {opts}) Shows document and optionally jumps to the location. Parameters: ~ - • {location} (`table`) (`Location`|`LocationLink`) + • {location} (`lsp.Location|lsp.LocationLink`) • {offset_encoding} (`string?`) utf-8|utf-16|utf-32 • {opts} (`table?`) options • reuse_win (boolean) Jump to existing window if @@ -2174,7 +2245,7 @@ stylize_markdown({bufnr}, {contents}, {opts}) Parameters: ~ • {bufnr} (`integer`) - • {contents} (`table`) of lines to show in window + • {contents} (`string[]`) of lines to show in window • {opts} (`table`) with optional fields • height of floating window • width of floating window @@ -2191,7 +2262,7 @@ symbols_to_items({symbols}, {bufnr}) *vim.lsp.util.symbols_to_items()* Parameters: ~ • {symbols} (`table`) DocumentSymbol[] or SymbolInformation[] - • {bufnr} (`integer`) + • {bufnr} (`integer?`) ============================================================================== @@ -2238,7 +2309,7 @@ Lua module: vim.lsp.rpc *lsp-rpc* *vim.lsp.rpc.PublicClient* Fields: ~ - • {request} (`fun(method: string, params: table?, callback: fun(err: lsp.ResponseError?, result: any), notify_reply_callback: fun(integer)?):boolean,integer?`) + • {request} (`fun(method: string, params: table?, callback: fun(err: lsp.ResponseError?, result: any), notify_reply_callback: fun(message_id: integer)?):boolean,integer?`) see |vim.lsp.rpc.request()| • {notify} (`fun(method: string, params: any):boolean`) see |vim.lsp.rpc.notify()| diff --git a/runtime/doc/lua-guide.txt b/runtime/doc/lua-guide.txt index e8757a1859..5f06d51f42 100644 --- a/runtime/doc/lua-guide.txt +++ b/runtime/doc/lua-guide.txt @@ -225,7 +225,6 @@ Vimscript are automatically converted: end vim.fn.jobstart('ls', { on_stdout = print_stdout }) - print(vim.fn.printf('Hello from %s', 'Lua')) < This works for both |builtin-functions| and |user-function|s. diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 3d8453c5a2..396f24a1aa 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -28,17 +28,18 @@ You can also run Lua scripts from your shell using the |-l| argument: > nvim -l foo.lua [args...] < *lua-compat* -Lua 5.1 is the permanent interface for Nvim Lua. Plugins need only consider -Lua 5.1, not worry about forward-compatibility with future Lua versions. If -Nvim ever ships with Lua 5.4+, a Lua 5.1 compatibility shim will be provided -so that old plugins continue to work transparently. +Lua 5.1 is the permanent interface for Nvim Lua. Plugins should target Lua 5.1 +as specified in |luaref|; later versions (which are essentially different, +incompatible, dialects) are not supported. This includes extensions such as +`goto` that some Lua 5.1 interpreters like LuaJIT may support. *lua-luajit* -On supported platforms, Nvim is built with LuaJIT, which provides extra -functionality (compared to PUC Lua) such as "bit" and various utilities (see -|lua-profile|). Lua code in |init.lua| and plugins can assume its presence on -many platforms, but for maximum compatibility should check the `jit` global -variable: >lua +While Nvim officially only requires Lua 5.1 support, it should be built with +LuaJIT or a compatible fork on supported platforms for performance reasons. +LuaJIT also comes with useful extensions such as `ffi`, |lua-profile|, and +enhanced standard library functions; these cannot be assumed to be available, +and Lua code in |init.lua| or plugins should check the `jit` global variable +before using them: >lua if jit then -- code for luajit else @@ -46,11 +47,12 @@ variable: >lua end < *lua-bit* -The LuaJIT "bit" extension module is _always_ available: when built with PUC -Lua, Nvim includes a fallback implementation which provides `require("bit")`. +One exception is the LuaJIT `bit` extension, which is always available: when +built with PUC Lua, Nvim includes a fallback implementation which provides +`require("bit")`. *lua-profile* -To profile Lua code (with LuaJIT-enabled Nvim), the basic steps are: >lua +If Nvim is built with LuaJIT, Lua code can be profiled via >lua -- Start a profiling session: require('jit.p').start('ri1', '/tmp/profile') @@ -59,13 +61,13 @@ To profile Lua code (with LuaJIT-enabled Nvim), the basic steps are: >lua -- Stop the session. Profile is written to /tmp/profile. require('jit.p').stop() -See https://luajit.org/ext_profiler.html or the "p.lua" source for details: > +See https://luajit.org/ext_profiler.html or the `p.lua` source for details: > :lua vim.cmd.edit(package.searchpath('jit.p', package.path)) ============================================================================== LUA CONCEPTS AND IDIOMS *lua-concepts* -Lua is very simple: this means that, while there are some quirks, once you +Lua is very simple, and _consistent_: while there are some quirks, once you internalize those quirks, everything works the same everywhere. Scopes (closures) in particular are very consistent, unlike JavaScript or most other languages. @@ -83,6 +85,36 @@ https://www.lua.org/doc/cacm2018.pdf - Stackful coroutines enable cooperative multithreading, generators, and versatile control for both Lua and its host (Nvim). + *lua-error-handling* +Lua functions may throw |lua-errors| for exceptional (unexpected) failures, +which you can handle with |pcall()|. + *lua-result-or-message* +When failure is normal and expected, it's idiomatic to return `nil` which +signals to the caller that failure is not "exceptional" and must be handled. +This "result-or-message" pattern is expressed as the multi-value return type +`any|nil,nil|string`, or in LuaLS notation: > + + ---@return any|nil # result on success, nil on failure. + ---@return nil|string # nil on success, error message on failure. +< +Examples of the "result-or-message" pattern: +- |vim.ui.open()| +- |io.open()| +- |luv-error-handling| + +When a caller can't proceed on failure, it's idiomatic to `assert()` the +"result-or-message" result: >lua + + local value = assert(fn()) + +Guidance: use the "result-or-message" pattern for... +- Functions where failure is expected, especially when communicating with the + external world. E.g. HTTP requests or LSP requests often fail because of + server problems, even if the caller did everything right. +- Functions that return a value, e.g. Foo:new(). +- When there is a list of known error codes which can be returned as a third + value (like |luv-error-handling|). +< *iterator* An iterator is just a function that can be called repeatedly to get the "next" value of a collection (or any other |iterable|). This interface is expected by @@ -350,16 +382,14 @@ Example: >vim < *lua-table-ambiguous* Lua tables are used as both dictionaries and lists, so it is impossible to -determine whether empty table is meant to be empty list or empty dictionary. -Additionally Lua does not have integer numbers. To distinguish between these -cases there is the following agreement: +decide whether empty table is a list or a dict. Also Lua does not have integer +numbers. To disambiguate these cases, we define: *lua-list* -0. Empty table is empty list. -1. Table with N consecutive integer indices starting from 1 and ending with - N is considered a list. See also |list-iterator|. +0. Empty table is a list. Use |vim.empty_dict()| to represent empty dict. +1. Table with N consecutive (no `nil` values, aka "holes") integer keys 1…N is + a list. See also |list-iterator|. *lua-dict* -2. Table with string keys, none of which contains NUL byte, is considered to - be a dictionary. +2. Table with string keys, none of which contains NUL byte, is a dict. 3. Table with string keys, at least one of which contains NUL byte, is also considered to be a dictionary, but this time it is converted to a |msgpack-special-map|. @@ -543,16 +573,19 @@ Example: File-change detection *watch-file* vim.api.nvim_command( "command! -nargs=1 Watch call luaeval('watch_file(_A)', expand('<args>'))") < - *fswatch-limitations* -When on Linux and using fswatch, you may need to increase the maximum number -of `inotify` watches and queued events as the default limit can be too low. To -increase the limit, run: >sh - sysctl fs.inotify.max_user_watches=100000 - sysctl fs.inotify.max_queued_events=100000 + *inotify-limitations* +When on Linux you may need to increase the maximum number of `inotify` watches +and queued events as the default limit can be too low. To increase the limit, +run: >sh + sysctl fs.inotify.max_user_watches=494462 < -This will increase the limit to 100000 watches and queued events. These lines +This will increase the limit to 494462 watches and queued events. These lines can be added to `/etc/sysctl.conf` to make the changes persistent. +Note that each watch is a structure in the Kernel, thus available memory is +also a bottleneck for using inotify. In fact, a watch can take up to 1KB of +space. This means a million watches could result in 1GB of extra RAM usage. + Example: TCP echo-server *tcp-server* 1. Save this code to a file. 2. Execute it with ":luafile %". @@ -646,8 +679,8 @@ vim.highlight.range({bufnr}, {ns}, {higroup}, {start}, {finish}, {opts}) • {finish} (`integer[]|string`) End of region as a (line, column) tuple or string accepted by |getpos()| • {opts} (`table?`) A table with the following fields: - • {regtype}? (`string`, default: `'charwise'`) Type of - range. See |setreg()| + • {regtype}? (`string`, default: `'v'` i.e. charwise) Type + of range. See |getregtype()| • {inclusive}? (`boolean`, default: `false`) Indicates whether the range is end-inclusive • {priority}? (`integer`, default: @@ -680,47 +713,47 @@ vim.diff({a}, {b}, {opts}) *vim.diff()* Parameters: ~ • {a} (`string`) First string to compare • {b} (`string`) Second string to compare - • {opts} (`table`) Optional parameters: - • {on_hunk} - (`fun(start_a: integer, count_a: integer, start_b: integer, count_b: integer): integer`) + • {opts} (`table?`) Optional parameters: + • {on_hunk}? + (`fun(start_a: integer, count_a: integer, start_b: integer, count_b: integer): integer?`) Invoked for each hunk in the diff. Return a negative number to cancel the callback for any remaining hunks. Arguments: • `start_a` (`integer`): Start line of hunk in {a}. • `count_a` (`integer`): Hunk size in {a}. • `start_b` (`integer`): Start line of hunk in {b}. • `count_b` (`integer`): Hunk size in {b}. - • {result_type} (`'unified'|'indices'`, default: `'unified'`) + • {result_type}? (`'unified'|'indices'`, default: `'unified'`) Form of the returned diff: • `unified`: String in unified format. • `indices`: Array of hunk locations. Note: This option is ignored if `on_hunk` is used. - • {linematch} (`boolean|integer`) Run linematch on the + • {linematch}? (`boolean|integer`) Run linematch on the resulting hunks from xdiff. When integer, only hunks upto this size in lines are run through linematch. Requires `result_type = indices`, ignored otherwise. - • {algorithm} (`'myers'|'minimal'|'patience'|'histogram'`, + • {algorithm}? (`'myers'|'minimal'|'patience'|'histogram'`, default: `'myers'`) Diff algorithm to use. Values: • `myers`: the default algorithm • `minimal`: spend extra time to generate the smallest possible diff • `patience`: patience diff algorithm • `histogram`: histogram diff algorithm - • {ctxlen} (`integer`) Context length - • {interhunkctxlen} (`integer`) Inter hunk context length - • {ignore_whitespace} (`boolean`) Ignore whitespace - • {ignore_whitespace_change} (`boolean`) Ignore whitespace + • {ctxlen}? (`integer`) Context length + • {interhunkctxlen}? (`integer`) Inter hunk context length + • {ignore_whitespace}? (`boolean`) Ignore whitespace + • {ignore_whitespace_change}? (`boolean`) Ignore whitespace change - • {ignore_whitespace_change_at_eol} (`boolean`) Ignore + • {ignore_whitespace_change_at_eol}? (`boolean`) Ignore whitespace change at end-of-line. - • {ignore_cr_at_eol} (`boolean`) Ignore carriage return at + • {ignore_cr_at_eol}? (`boolean`) Ignore carriage return at end-of-line - • {ignore_blank_lines} (`boolean`) Ignore blank lines - • {indent_heuristic} (`boolean`) Use the indent heuristic for + • {ignore_blank_lines}? (`boolean`) Ignore blank lines + • {indent_heuristic}? (`boolean`) Use the indent heuristic for the internal diff library. Return: ~ - (`string|integer[]`) See {opts.result_type}. `nil` if {opts.on_hunk} - is given. + (`string|integer[][]?`) See {opts.result_type}. `nil` if + {opts.on_hunk} is given. ============================================================================== @@ -834,8 +867,8 @@ vim.spell.check({str}) *vim.spell.check()* • {str} (`string`) Return: ~ - (`{[1]: string, [2]: 'bad'|'rare'|'local'|'caps', [3]: integer}[]`) - List of tuples with three items: + (`[string, 'bad'|'rare'|'local'|'caps', integer][]`) List of tuples + with three items: • The badly spelled word. • The type of the spelling error: "bad" spelling mistake "rare" rare word "local" word only valid in another region "caps" word should @@ -981,6 +1014,9 @@ vim.str_byteindex({str}, {index}, {use_utf16}) *vim.str_byteindex()* • {index} (`integer`) • {use_utf16} (`boolean?`) + Return: ~ + (`integer`) + vim.str_utf_end({str}, {index}) *vim.str_utf_end()* Gets the distance (in bytes) from the last byte of the codepoint (character) that {index} points to. @@ -1067,7 +1103,9 @@ vim.stricmp({a}, {b}) *vim.stricmp()* lesser than {b}, respectively. vim.ui_attach({ns}, {options}, {callback}) *vim.ui_attach()* - Attach to ui events, similar to |nvim_ui_attach()| but receive events as + WARNING: This feature is experimental/unstable. + + Attach to |ui-events|, similar to |nvim_ui_attach()| but receive events as Lua callback. Can be used to implement screen elements like popupmenu or message handling in Lua. @@ -1660,8 +1698,11 @@ vim.on_key({fn}, {ns_id}) *vim.on_key()* callbacks if on_key() is called without arguments. vim.paste({lines}, {phase}) *vim.paste()* - Paste handler, invoked by |nvim_paste()| when a conforming UI (such as the - |TUI|) pastes text into the editor. + Paste handler, invoked by |nvim_paste()|. + + Note: This is provided only as a "hook", don't call it directly; call + |nvim_paste()| instead, which arranges redo (dot-repeat) and invokes + `vim.paste`. Example: To remove ANSI color codes when pasting: >lua vim.paste = (function(overridden) @@ -1670,7 +1711,7 @@ vim.paste({lines}, {phase}) *vim.paste()* -- Scrub ANSI color codes from paste input. lines[i] = line:gsub('\27%[[0-9;mK]+', '') end - overridden(lines, phase) + return overridden(lines, phase) end end)(vim.paste) < @@ -1708,30 +1749,6 @@ vim.print({...}) *vim.print()* • |vim.inspect()| • |:=| - *vim.region()* -vim.region({bufnr}, {pos1}, {pos2}, {regtype}, {inclusive}) - Gets a dict of line segment ("chunk") positions for the region from `pos1` - to `pos2`. - - Input and output positions are byte positions, (0,0)-indexed. "End of - line" column position (for example, |linewise| visual selection) is - returned as |v:maxcol| (big number). - - Parameters: ~ - • {bufnr} (`integer`) Buffer number, or 0 for current buffer - • {pos1} (`integer[]|string`) Start of region as a (line, column) - tuple or |getpos()|-compatible string - • {pos2} (`integer[]|string`) End of region as a (line, column) - tuple or |getpos()|-compatible string - • {regtype} (`string`) |setreg()|-style selection type - • {inclusive} (`boolean`) Controls whether the ending column is - inclusive (see also 'selection'). - - Return: ~ - (`table`) region Dict of the form `{linenr = {startcol,endcol}}`. - `endcol` is exclusive, and whole lines are returned as - `{startcol,endcol} = {0,-1}`. - vim.schedule_wrap({fn}) *vim.schedule_wrap()* Returns a function which calls {fn} via |vim.schedule()|. @@ -1841,6 +1858,9 @@ vim.inspect_pos({bufnr}, {row}, {col}, {filter}) *vim.inspect_pos()* Can also be pretty-printed with `:Inspect!`. *:Inspect!* + Attributes: ~ + Since: 0.9.0 + Parameters: ~ • {bufnr} (`integer?`) defaults to the current buffer • {row} (`integer?`) row to inspect, 0-based. Defaults to the row of @@ -1874,6 +1894,9 @@ vim.show_pos({bufnr}, {row}, {col}, {filter}) *vim.show_pos()* Can also be shown with `:Inspect`. *:Inspect* + Attributes: ~ + Since: 0.9.0 + Parameters: ~ • {bufnr} (`integer?`) defaults to the current buffer • {row} (`integer?`) row to inspect, 0-based. Defaults to the row of @@ -2248,6 +2271,12 @@ vim.tbl_count({t}) *vim.tbl_count()* vim.tbl_deep_extend({behavior}, {...}) *vim.tbl_deep_extend()* Merges recursively two or more tables. + Only values that are empty tables or tables that are not |lua-list|s + (indexed by consecutive integers starting from 1) are merged recursively. + This is useful for merging nested tables like default and user + configurations where lists should be treated as literals (i.e., are + overwritten instead of merged). + Parameters: ~ • {behavior} (`'error'|'keep'|'force'`) Decides what to do if a key is found in more than one map: @@ -2366,7 +2395,26 @@ vim.trim({s}) *vim.trim()* • https://www.lua.org/pil/20.2.html vim.validate({opt}) *vim.validate()* - Validates a parameter specification (types and values). Specs are + Validate function arguments. + + This function has two valid forms: + 1. vim.validate(name: str, value: any, type: string, optional?: bool) + 2. vim.validate(spec: table) + + Form 1 validates that argument {name} with value {value} has the type + {type}. {type} must be a value returned by |lua-type()|. If {optional} is + true, then {value} may be null. This form is significantly faster and + should be preferred for simple cases. + + Example: >lua + function vim.startswith(s, prefix) + vim.validate('s', s, 'string') + vim.validate('prefix', prefix, 'string') + ... + end +< + + Form 2 validates a parameter specification (types and values). Specs are evaluated in alphanumeric order, until the first failure. Usage example: >lua @@ -2421,11 +2469,15 @@ vim.validate({opt}) *vim.validate()* Lua module: vim.loader *vim.loader* vim.loader.disable() *vim.loader.disable()* + WARNING: This feature is experimental/unstable. + Disables the experimental Lua module loader: • removes the loaders • adds the default Nvim loader vim.loader.enable() *vim.loader.enable()* + WARNING: This feature is experimental/unstable. + Enables the experimental Lua module loader: • overrides loadfile • adds the Lua loader using the byte-compilation cache @@ -2433,6 +2485,8 @@ vim.loader.enable() *vim.loader.enable()* • removes the default Nvim loader vim.loader.find({modname}, {opts}) *vim.loader.find()* + WARNING: This feature is experimental/unstable. + Finds Lua modules for the given module name. Parameters: ~ @@ -2458,6 +2512,8 @@ vim.loader.find({modname}, {opts}) *vim.loader.find()* returned for `modname="*"` vim.loader.reset({path}) *vim.loader.reset()* + WARNING: This feature is experimental/unstable. + Resets the cache for the path, or all the paths if path is nil. Parameters: ~ @@ -2552,7 +2608,7 @@ vim.ui.input({opts}, {on_confirm}) *vim.ui.input()* typed (it might be an empty string if nothing was entered), or `nil` if the user aborted the dialog. -vim.ui.open({path}) *vim.ui.open()* +vim.ui.open({path}, {opt}) *vim.ui.open()* Opens `path` with the system default handler (macOS `open`, Windows `explorer.exe`, Linux `xdg-open`, …), or returns (but does not show) an error message on failure. @@ -2563,6 +2619,8 @@ vim.ui.open({path}) *vim.ui.open()* -- Asynchronous. vim.ui.open("https://neovim.io/") vim.ui.open("~/path/to/file") + -- Use the "osurl" command to handle the path or URL. + vim.ui.open("gh#neovim/neovim!29490", { cmd = { 'osurl' } }) -- Synchronous (wait until the process exits). local cmd, err = vim.ui.open("$VIMRUNTIME") if cmd then @@ -2572,6 +2630,8 @@ vim.ui.open({path}) *vim.ui.open()* Parameters: ~ • {path} (`string`) Path or URL to open + • {opt} (`{ cmd?: string[] }?`) Options + • cmd string[]|nil Command used to open the path or URL. Return (multiple): ~ (`vim.SystemObj?`) Command object, or nil if not found. @@ -2671,7 +2731,7 @@ vim.filetype.add({filetypes}) *vim.filetype.add()* ['.*/etc/foo/.*%.conf'] = { 'dosini', { priority = 10 } }, -- A pattern containing an environment variable ['${XDG_CONFIG_HOME}/foo/git'] = 'git', - ['README.(%a+)$'] = function(path, bufnr, ext) + ['.*README.(%a+)'] = function(path, bufnr, ext) if ext == 'md' then return 'markdown' elseif ext == 'rst' then @@ -2723,6 +2783,9 @@ vim.filetype.get_option({filetype}, {option}) means |ftplugin| and |FileType| autocommands are only triggered once and may not reflect later changes. + Attributes: ~ + Since: 0.9.0 + Parameters: ~ • {filetype} (`string`) Filetype • {option} (`string`) Option name @@ -2803,24 +2866,24 @@ vim.keymap.del({modes}, {lhs}, {opts}) *vim.keymap.del()* • |vim.keymap.set()| vim.keymap.set({mode}, {lhs}, {rhs}, {opts}) *vim.keymap.set()* - Adds a new |mapping|. Examples: >lua - -- Map to a Lua function: - vim.keymap.set('n', 'lhs', function() print("real lua function") end) - -- Map to multiple modes: - vim.keymap.set({'n', 'v'}, '<leader>lr', vim.lsp.buf.references, { buffer = true }) - -- Buffer-local mapping: - vim.keymap.set('n', '<leader>w', "<cmd>w<cr>", { silent = true, buffer = 5 }) - -- Expr mapping: + Defines a |mapping| of |keycodes| to a function or keycodes. + + Examples: >lua + -- Map "x" to a Lua function: + vim.keymap.set('n', 'x', function() print("real lua function") end) + -- Map "<leader>x" to multiple modes for the current buffer: + vim.keymap.set({'n', 'v'}, '<leader>x', vim.lsp.buf.references, { buffer = true }) + -- Map <Tab> to an expression (|:map-<expr>|): vim.keymap.set('i', '<Tab>', function() return vim.fn.pumvisible() == 1 and "<C-n>" or "<Tab>" end, { expr = true }) - -- <Plug> mapping: + -- Map "[%%" to a <Plug> mapping: vim.keymap.set('n', '[%%', '<Plug>(MatchitNormalMultiBackward)') < Parameters: ~ - • {mode} (`string|string[]`) Mode short-name, see |nvim_set_keymap()|. - Can also be list of modes to create mapping on multiple modes. + • {mode} (`string|string[]`) Mode "short-name" (see + |nvim_set_keymap()|), or a list thereof. • {lhs} (`string`) Left-hand side |{lhs}| of the mapping. • {rhs} (`string|function`) Right-hand side |{rhs}| of the mapping, can be a Lua function. @@ -2847,6 +2910,9 @@ Lua module: vim.fs *vim.fs* vim.fs.basename({file}) *vim.fs.basename()* Return the basename of the given path + Attributes: ~ + Since: 0.8.0 + Parameters: ~ • {file} (`string?`) Path @@ -2856,6 +2922,9 @@ vim.fs.basename({file}) *vim.fs.basename()* vim.fs.dir({path}, {opts}) *vim.fs.dir()* Return an iterator over the items located in {path} + Attributes: ~ + Since: 0.8.0 + Parameters: ~ • {path} (`string`) An absolute or relative path to the directory to iterate over. The path is first normalized @@ -2875,6 +2944,9 @@ vim.fs.dir({path}, {opts}) *vim.fs.dir()* vim.fs.dirname({file}) *vim.fs.dirname()* Return the parent directory of the given path + Attributes: ~ + Since: 0.8.0 + Parameters: ~ • {file} (`string?`) Path @@ -2907,6 +2979,9 @@ vim.fs.find({names}, {opts}) *vim.fs.find()* end, {limit = math.huge, type = 'file'}) < + Attributes: ~ + Since: 0.8.0 + Parameters: ~ • {names} (`string|string[]|fun(name: string, path: string): boolean`) Names of the items to find. Must be base names, paths and @@ -2938,6 +3013,9 @@ vim.fs.joinpath({...}) *vim.fs.joinpath()* Concatenate directories and/or file paths into a single path with normalization (e.g., `"foo/"` and `"bar"` get joined to `"foo/bar"`) + Attributes: ~ + Since: 0.10.0 + Parameters: ~ • {...} (`string`) @@ -2974,6 +3052,9 @@ vim.fs.normalize({path}, {opts}) *vim.fs.normalize()* [[\\?\UNC\server\share\foo\..\..\..\bar]] => "//?/UNC/server/share/bar" < + Attributes: ~ + Since: 0.8.0 + Parameters: ~ • {path} (`string`) Path to normalize • {opts} (`table?`) A table with the following fields: @@ -3002,6 +3083,9 @@ vim.fs.parents({start}) *vim.fs.parents()* end < + Attributes: ~ + Since: 0.8.0 + Parameters: ~ • {start} (`string`) Initial path. @@ -3010,6 +3094,18 @@ vim.fs.parents({start}) *vim.fs.parents()* (`nil`) (`string?`) +vim.fs.rm({path}, {opts}) *vim.fs.rm()* + WARNING: This feature is experimental/unstable. + + Remove files or directories + + Parameters: ~ + • {path} (`string`) Path to remove + • {opts} (`table?`) A table with the following fields: + • {recursive}? (`boolean`) Remove directories and their + contents recursively + • {force}? (`boolean`) Ignore nonexistent files and arguments + vim.fs.root({source}, {marker}) *vim.fs.root()* Find the first parent directory containing a specific "marker", relative to a file path or buffer. @@ -3030,6 +3126,9 @@ vim.fs.root({source}, {marker}) *vim.fs.root()* end) < + Attributes: ~ + Since: 0.10.0 + Parameters: ~ • {source} (`integer|string`) Buffer number (0 for current buffer) or file path (absolute or relative to the |current-directory|) @@ -3089,7 +3188,7 @@ In addition, its regex-like interface is available as |vim.re| -Pattern:match({subject}, {init}) *Pattern:match()* +Pattern:match({subject}, {init}, {...}) *Pattern:match()* Matches the given `pattern` against the `subject` string. If the match succeeds, returns the index in the subject of the first character after the match, or the captured values (if the pattern captured any value). An @@ -3112,9 +3211,10 @@ Pattern:match({subject}, {init}) *Pattern:match()* Parameters: ~ • {subject} (`string`) • {init} (`integer?`) + • {...} (`any`) Return: ~ - (`integer|vim.lpeg.Capture?`) + (`any`) ... vim.lpeg.B({pattern}) *vim.lpeg.B()* Returns a pattern that matches only if the input string at the current @@ -3124,7 +3224,7 @@ vim.lpeg.B({pattern}) *vim.lpeg.B()* or failure. Parameters: ~ - • {pattern} (`vim.lpeg.Pattern`) + • {pattern} (`vim.lpeg.Pattern|string|integer|boolean|table`) Return: ~ (`vim.lpeg.Pattern`) @@ -3148,7 +3248,7 @@ vim.lpeg.C({patt}) *vim.lpeg.C()* < Parameters: ~ - • {patt} (`vim.lpeg.Pattern`) + • {patt} (`vim.lpeg.Pattern|string|integer|boolean|table|function`) Return: ~ (`vim.lpeg.Capture`) @@ -3199,11 +3299,11 @@ vim.lpeg.Cf({patt}, {func}) *vim.lpeg.Cf()* This capture assumes that `patt` should produce at least one capture with at least one value (of any type), which becomes the initial value of an accumulator. (If you need a specific initial value, you may prefix a - constant captureto `patt`.) For each subsequent capture, LPeg calls `func` - with this accumulator as the first argument and all values produced by the - capture as extra arguments; the first result from this call becomes the - new value for the accumulator. The final value of the accumulator becomes - the captured value. + constant capture to `patt`.) For each subsequent capture, LPeg calls + `func` with this accumulator as the first argument and all values produced + by the capture as extra arguments; the first result from this call becomes + the new value for the accumulator. The final value of the accumulator + becomes the captured value. Example: >lua local number = lpeg.R('09') ^ 1 / tonumber @@ -3214,7 +3314,7 @@ vim.lpeg.Cf({patt}, {func}) *vim.lpeg.Cf()* < Parameters: ~ - • {patt} (`vim.lpeg.Pattern`) + • {patt} (`vim.lpeg.Pattern|string|integer|boolean|table|function`) • {func} (`fun(acc, newvalue)`) Return: ~ @@ -3226,7 +3326,7 @@ vim.lpeg.Cg({patt}, {name}) *vim.lpeg.Cg()* with the given name (which can be any non-nil Lua value). Parameters: ~ - • {patt} (`vim.lpeg.Pattern`) + • {patt} (`vim.lpeg.Pattern|string|integer|boolean|table|function`) • {name} (`string?`) Return: ~ @@ -3249,8 +3349,9 @@ vim.lpeg.Cmt({patt}, {fn}) *vim.lpeg.Cmt()* function become the values produced by the capture. Parameters: ~ - • {patt} (`vim.lpeg.Pattern`) - • {fn} (`function`) + • {patt} (`vim.lpeg.Pattern|string|integer|boolean|table|function`) + • {fn} (`fun(s: string, i: integer, ...: any)`) (position: + boolean|integer, ...: any) Return: ~ (`vim.lpeg.Capture`) @@ -3289,7 +3390,7 @@ vim.lpeg.Cs({patt}) *vim.lpeg.Cs()* < Parameters: ~ - • {patt} (`vim.lpeg.Pattern`) + • {patt} (`vim.lpeg.Pattern|string|integer|boolean|table|function`) Return: ~ (`vim.lpeg.Capture`) @@ -3302,7 +3403,7 @@ vim.lpeg.Ct({patt}) *vim.lpeg.Ct()* the group name as its key. The captured value is only the table. Parameters: ~ - • {patt} (`vim.lpeg.Pattern|''`) + • {patt} (`vim.lpeg.Pattern|string|integer|boolean|table|function`) Return: ~ (`vim.lpeg.Capture`) @@ -3337,7 +3438,7 @@ vim.lpeg.locale({tab}) *vim.lpeg.locale()* Return: ~ (`vim.lpeg.Locale`) -vim.lpeg.match({pattern}, {subject}, {init}) *vim.lpeg.match()* +vim.lpeg.match({pattern}, {subject}, {init}, {...}) *vim.lpeg.match()* Matches the given `pattern` against the `subject` string. If the match succeeds, returns the index in the subject of the first character after the match, or the captured values (if the pattern captured any value). An @@ -3358,12 +3459,13 @@ vim.lpeg.match({pattern}, {subject}, {init}) *vim.lpeg.match()* < Parameters: ~ - • {pattern} (`vim.lpeg.Pattern`) + • {pattern} (`vim.lpeg.Pattern|string|integer|boolean|table|function`) • {subject} (`string`) • {init} (`integer?`) + • {...} (`any`) Return: ~ - (`integer|vim.lpeg.Capture?`) + (`any`) ... vim.lpeg.P({value}) *vim.lpeg.P()* Converts the given value into a proper pattern. The following rules are @@ -3457,7 +3559,7 @@ vim.lpeg.V({v}) *vim.lpeg.V()* < Parameters: ~ - • {v} (`string|integer`) + • {v} (`boolean|string|number|function|table|thread|userdata|lightuserdata`) Return: ~ (`vim.lpeg.Pattern`) @@ -3550,10 +3652,10 @@ within a single line. *regex:match_line()* regex:match_line({bufnr}, {line_idx}, {start}, {end_}) - Match line {line_idx} (zero-based) in buffer {bufnr}. If {start} and {end} - are supplied, match only this byte index range. Otherwise see - |regex:match_str()|. If {start} is used, then the returned byte indices - will be relative {start}. + Matches line at `line_idx` (zero-based) in buffer `bufnr`. Match is + restricted to byte index range `start` and `end_` if given, otherwise see + |regex:match_str()|. Returned byte indices are relative to `start` if + given. Parameters: ~ • {bufnr} (`integer`) @@ -3561,19 +3663,28 @@ regex:match_line({bufnr}, {line_idx}, {start}, {end_}) • {start} (`integer?`) • {end_} (`integer?`) + Return (multiple): ~ + (`integer?`) match start (byte index) relative to `start`, or `nil` if + no match + (`integer?`) match end (byte index) relative to `start`, or `nil` if + no match + regex:match_str({str}) *regex:match_str()* - Match the string against the regex. If the string should match the regex - precisely, surround the regex with `^` and `$`. If there was a match, the - byte indices for the beginning and end of the match are returned. When - there is no match, `nil` is returned. Because any integer is "truthy", - `regex:match_str()` can be directly used as a condition in an - if-statement. + Matches string `str` against this regex. To match the string precisely, + surround the regex with "^" and "$". Returns the byte indices for the + start and end of the match, or `nil` if there is no match. Because any + integer is "truthy", `regex:match_str()` can be directly used as a + condition in an if-statement. Parameters: ~ • {str} (`string`) + Return (multiple): ~ + (`integer?`) match start (byte index), or `nil` if no match + (`integer?`) match end (byte index), or `nil` if no match + vim.regex({re}) *vim.regex()* - Parse the Vim regex {re} and return a regex object. Regexes are "magic" + Parses the Vim regex `re` and returns a regex object. Regexes are "magic" and case-sensitive by default, regardless of 'magic' and 'ignorecase'. They can be controlled with flags, see |/magic| and |/ignorecase|. @@ -3592,6 +3703,9 @@ vim.secure.read({path}) *vim.secure.read()* be trusted. The user's choice is persisted in a trust database at $XDG_STATE_HOME/nvim/trust. + Attributes: ~ + Since: 0.9.0 + Parameters: ~ • {path} (`string`) Path to a file to read. @@ -3607,6 +3721,9 @@ vim.secure.trust({opts}) *vim.secure.trust()* The trust database is located at |$XDG_STATE_HOME|/nvim/trust. + Attributes: ~ + Since: 0.9.0 + Parameters: ~ • {opts} (`table`) A table with the following fields: • {action} (`'allow'|'deny'|'remove'`) - `'allow'` to add a @@ -3698,6 +3815,9 @@ vim.version.cmp({v1}, {v2}) *vim.version.cmp()* • Per semver, build metadata is ignored when comparing two otherwise-equivalent versions. + Attributes: ~ + Since: 0.9.0 + Parameters: ~ • {v1} (`vim.Version|number[]|string`) Version object. • {v2} (`vim.Version|number[]|string`) Version to compare with `v1`. @@ -3709,6 +3829,9 @@ vim.version.eq({v1}, {v2}) *vim.version.eq()* Returns `true` if the given versions are equal. See |vim.version.cmp()| for usage. + Attributes: ~ + Since: 0.9.0 + Parameters: ~ • {v1} (`vim.Version|number[]|string`) • {v2} (`vim.Version|number[]|string`) @@ -3719,6 +3842,9 @@ vim.version.eq({v1}, {v2}) *vim.version.eq()* vim.version.ge({v1}, {v2}) *vim.version.ge()* Returns `true` if `v1 >= v2`. See |vim.version.cmp()| for usage. + Attributes: ~ + Since: 0.10.0 + Parameters: ~ • {v1} (`vim.Version|number[]|string`) • {v2} (`vim.Version|number[]|string`) @@ -3729,6 +3855,9 @@ vim.version.ge({v1}, {v2}) *vim.version.ge()* vim.version.gt({v1}, {v2}) *vim.version.gt()* Returns `true` if `v1 > v2`. See |vim.version.cmp()| for usage. + Attributes: ~ + Since: 0.9.0 + Parameters: ~ • {v1} (`vim.Version|number[]|string`) • {v2} (`vim.Version|number[]|string`) @@ -3748,6 +3877,9 @@ vim.version.last({versions}) *vim.version.last()* vim.version.le({v1}, {v2}) *vim.version.le()* Returns `true` if `v1 <= v2`. See |vim.version.cmp()| for usage. + Attributes: ~ + Since: 0.10.0 + Parameters: ~ • {v1} (`vim.Version|number[]|string`) • {v2} (`vim.Version|number[]|string`) @@ -3758,6 +3890,9 @@ vim.version.le({v1}, {v2}) *vim.version.le()* vim.version.lt({v1}, {v2}) *vim.version.lt()* Returns `true` if `v1 < v2`. See |vim.version.cmp()| for usage. + Attributes: ~ + Since: 0.9.0 + Parameters: ~ • {v1} (`vim.Version|number[]|string`) • {v2} (`vim.Version|number[]|string`) @@ -3772,6 +3907,9 @@ vim.version.parse({version}, {opts}) *vim.version.parse()* { major = 1, minor = 0, patch = 1, prerelease = "rc1", build = "build.2" } < + Attributes: ~ + Since: 0.9.0 + Parameters: ~ • {version} (`string`) Version string to parse. • {opts} (`table?`) Optional keyword arguments: @@ -3812,6 +3950,9 @@ vim.version.range({spec}) *vim.version.range()* print(vim.version.ge({1,0,3}, r.from) and vim.version.lt({1,0,3}, r.to)) < + Attributes: ~ + Since: 0.9.0 + Parameters: ~ • {spec} (`string`) Version range "spec" @@ -3833,10 +3974,12 @@ argument into an *Iter* object with methods (such as |Iter:filter()| and chained to create iterator "pipelines": the output of each pipeline stage is input to the next stage. The first stage depends on the type passed to `vim.iter()`: -• List tables (arrays, |lua-list|) yield only the value of each element. - • Holes (nil values) are allowed. +• Lists or arrays (|lua-list|) yield only the value of each element. + • Holes (nil values) are allowed (but discarded). + • Use pairs() to treat array/list tables as dicts (preserve holes and + non-contiguous integer keys): `vim.iter(pairs(…))`. • Use |Iter:enumerate()| to also pass the index to the next stage. - • Or initialize with ipairs(): `vim.iter(ipairs(…))`. + • Or initialize with ipairs(): `vim.iter(ipairs(…))`. • Non-list tables (|lua-dict|) yield both the key and value of each element. • Function |iterator|s yield all values returned by the underlying function. • Tables with a |__call()| metamethod are treated as function iterators. @@ -4084,10 +4227,10 @@ Iter:map({f}) *Iter:map()* < Parameters: ~ - • {f} (`fun(...):any`) Mapping function. Takes all values returned from - the previous stage in the pipeline as arguments and returns one - or more new values, which are used in the next pipeline stage. - Nil return values are filtered from the output. + • {f} (`fun(...):...:any`) Mapping function. Takes all values returned + from the previous stage in the pipeline as arguments and returns + one or more new values, which are used in the next pipeline + stage. Nil return values are filtered from the output. Return: ~ (`Iter`) @@ -4332,7 +4475,7 @@ vim.snippet.active({filter}) *vim.snippet.active()* You can use this function to navigate a snippet as follows: >lua vim.keymap.set({ 'i', 's' }, '<Tab>', function() if vim.snippet.active({ direction = 1 }) then - return '<cmd>lua vim.snippet.jump(1)<cr>' + return '<Cmd>lua vim.snippet.jump(1)<CR>' else return '<Tab>' end @@ -4366,7 +4509,7 @@ vim.snippet.jump({direction}) *vim.snippet.jump()* For example, map `<Tab>` to jump while a snippet is active: >lua vim.keymap.set({ 'i', 's' }, '<Tab>', function() if vim.snippet.active({ direction = 1 }) then - return '<cmd>lua vim.snippet.jump(1)<cr>' + return '<Cmd>lua vim.snippet.jump(1)<CR>' else return '<Tab>' end @@ -4390,8 +4533,9 @@ vim.text.hexdecode({enc}) *vim.text.hexdecode()* Parameters: ~ • {enc} (`string`) String to decode - Return: ~ - (`string`) Decoded string + Return (multiple): ~ + (`string?`) Decoded string + (`string?`) Error message, if any vim.text.hexencode({str}) *vim.text.hexencode()* Hex encode a string. @@ -4407,7 +4551,7 @@ vim.text.hexencode({str}) *vim.text.hexencode()* Lua module: tohtml *vim.tohtml* -:TOhtml {file} *:TOhtml* +:[range]TOhtml {file} *:TOhtml* Converts the buffer shown in the current window to HTML, opens the generated HTML in a new split window, and saves its contents to {file}. If {file} is not given, a temporary file (created by |tempname()|) is used. @@ -4429,6 +4573,8 @@ tohtml.tohtml({winid}, {opt}) *tohtml.tohtml.tohtml()* • {width}? (`integer`, default: 'textwidth' if non-zero or window width otherwise) Width used for items which are either right aligned or repeat a character infinitely. + • {range}? (`integer[]`, default: entire buffer) Range of + rows to use. Return: ~ (`string[]`) diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 9ec34d5d52..7fd1f3bfbb 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -354,7 +354,8 @@ Note: *E1255* *E1136* <Cmd> commands must terminate, that is, they must be followed by <CR> in the -{rhs} of the mapping definition. |Command-line| mode is never entered. +{rhs} of the mapping definition. |Command-line| mode is never entered. To use +a literal <CR> in the {rhs}, use |<lt>|. 1.3 MAPPING AND MODES *:map-modes* @@ -1380,12 +1381,14 @@ completion can be enabled: -complete=arglist file names in argument list -complete=augroup autocmd groups + -complete=breakpoint |:breakadd| suboptions -complete=buffer buffer names - -complete=behave :behave suboptions -complete=color color schemes -complete=command Ex command (and arguments) -complete=compiler compilers + -complete=diff_buffer diff buffer names -complete=dir directory names + -complete=dir_in_path directory names in |'cdpath'| -complete=environment environment variable names -complete=event autocommand events -complete=expression Vim expression @@ -1395,7 +1398,7 @@ completion can be enabled: -complete=function function name -complete=help help subjects -complete=highlight highlight groups - -complete=history :history suboptions + -complete=history |:history| suboptions -complete=keymap keyboard mappings -complete=locale locale names (as output of locale -a) -complete=lua Lua expression |:lua| @@ -1405,6 +1408,8 @@ completion can be enabled: -complete=messages |:messages| suboptions -complete=option options -complete=packadd optional package |pack-add| names + -complete=runtime file and directory names in |'runtimepath'| + -complete=scriptnames sourced script names -complete=shellcmd Shell command -complete=sign |:sign| suboptions -complete=syntax syntax file names |'syntax'| @@ -1679,7 +1684,7 @@ The valid escape sequences are nothing. Supported modifiers are |:aboveleft|, |:belowright|, |:botright|, |:browse|, |:confirm|, |:hide|, |:horizontal|, |:keepalt|, |:keepjumps|, |:keepmarks|, |:keeppatterns|, - |:leftabove|, |:lockmarks|, |:noautocmd|, |:noswapfile| + |:leftabove|, |:lockmarks|, |:noautocmd|, |:noswapfile|, |:rightbelow|, |:sandbox|, |:silent|, |:tab|, |:topleft|, |:unsilent|, |:verbose|, and |:vertical|. Note that |:filter| is not supported. diff --git a/runtime/doc/mbyte.txt b/runtime/doc/mbyte.txt index 0a7e0baad3..47fd4f3343 100644 --- a/runtime/doc/mbyte.txt +++ b/runtime/doc/mbyte.txt @@ -646,6 +646,12 @@ widespread as file format. A composing or combining character is used to change the meaning of the character before it. The combining characters are drawn on top of the preceding character. + +Nvim largely follows the definition of extended grapheme clusters in UAX#29 +in the Unicode standard, with some modifications: An ascii char will always +start a new cluster. In addition 'arabicshape' enables the combining of some +arabic letters, when they are shaped to be displayed together in a single cell. + Too big combined characters cannot be displayed, but they can still be inspected using the |g8| and |ga| commands described below. When editing text a composing character is mostly considered part of the @@ -686,7 +692,7 @@ You might want to select the font used for the menus. Unfortunately this doesn't always work. See the system specific remarks below, and 'langmenu'. -USING UTF-8 IN X-Windows *utf-8-in-xwindows* +USING UTF-8 IN X-WINDOWS *utf-8-in-xwindows* You need to specify a font to be used. For double-wide characters another font is required, which is exactly twice as wide. There are three ways to do diff --git a/runtime/doc/message.txt b/runtime/doc/message.txt index afe64300e7..ac151811c2 100644 --- a/runtime/doc/message.txt +++ b/runtime/doc/message.txt @@ -690,6 +690,7 @@ Ex command or function was given an invalid argument. Or |jobstart()| or *E488* > Trailing characters + Trailing characters: {text} An argument was given to an Ex command that does not permit one. Or the argument has invalid characters and has not been recognized. @@ -756,7 +757,7 @@ src/ex_cmds.lua. Update the lookup table by re-running the build. > This is an (incomplete) overview of various messages that Vim gives: *hit-enter* *press-enter* *hit-return* - *press-return* *hit-enter-prompt* + *press-return* *hit-enter-prompt* > Press ENTER or type command to continue diff --git a/runtime/doc/motion.txt b/runtime/doc/motion.txt index e80969c583..48e13d795e 100644 --- a/runtime/doc/motion.txt +++ b/runtime/doc/motion.txt @@ -60,10 +60,12 @@ When doubling the operator it operates on a line. When using a count, before or after the first character, that many lines are operated upon. Thus `3dd` deletes three lines. A count before and after the first character is multiplied, thus `2y3y` yanks six lines. - + *operator-resulting-pos* After applying the operator the cursor is mostly left at the start of the text that was operated upon. For example, "yfe" doesn't move the cursor, but "yFe" moves the cursor leftwards to the "e" where the yank started. +The 'startofline' option applies only to the "d", "<<", "==" and ">>" linewise +operations. *linewise* *charwise* *characterwise* The operator either affects whole lines, or the characters between the start @@ -162,9 +164,9 @@ h or *h* CTRL-H or *CTRL-H* *<BS>* <BS> [count] characters to the left. |exclusive| motion. Note: If you prefer <BS> to delete a character, use - the mapping: + the mapping: > :map CTRL-V<BS> X - (to enter "CTRL-V<BS>" type the CTRL-V key, followed +< (to enter "CTRL-V<BS>" type the CTRL-V key, followed by the <BS> key) l or *l* @@ -342,6 +344,7 @@ gg Goto line [count], default first line, on the first *:[range]* :[range] Set the cursor on the last line number in [range]. + In Ex mode, print the lines in [range]. [range] can also be just one line number, e.g., ":1" or ":'m". In contrast with |G| this command does not modify the @@ -354,11 +357,11 @@ gg Goto line [count], default first line, on the first See also 'startofline' option. :[range]go[to] [count] *:go* *:goto* *go* -[count]go Go to [count] byte in the buffer. Default [count] is - one, start of the file. When giving [range], the - last number in it used as the byte count. End-of-line - characters are counted depending on the current - 'fileformat' setting. +[count]go Go to [count] byte in the buffer. |exclusive| motion. + Default [count] is one, start of the file. When + giving [range], the last number in it used as the byte + count. End-of-line characters are counted depending + on the current 'fileformat' setting. Also see the |line2byte()| function, and the 'o' option in 'statusline'. diff --git a/runtime/doc/news-0.10.txt b/runtime/doc/news-0.10.txt index 8a0e7e92e7..a5ded1ca22 100644 --- a/runtime/doc/news-0.10.txt +++ b/runtime/doc/news-0.10.txt @@ -155,8 +155,6 @@ The following new features were added. • |nvim_input_mouse()| supports mouse buttons "x1" and "x2". • Added "force_crlf" option field in |nvim_open_term()|. • Added |nvim_tabpage_set_win()| to set the current window of a tabpage. - • |nvim__win_add_ns()| can bind a |namespace| to a window-local scope(s). - • Extmarks opt-in to this scoping via the `scoped` flag of |nvim_buf_set_extmark()|. • Mapping APIs now support abbreviations when mode short-name has suffix "a". • Floating windows can now show footer with new `footer` and `footer_pos` config fields. Uses |hl-FloatFooter| by default. @@ -307,7 +305,7 @@ The following new features were added. a predicate function that is checked for each value. (Use |vim.list_contains()| for checking list-like tables (integer keys without gaps) for literal values.) - • |vim.region()| can use a string accepted by |getpos()| as position. + • vim.region() can use a string accepted by |getpos()| as position. • Options: • 'winfixbuf' keeps a window focused onto a specific buffer @@ -349,8 +347,8 @@ The following new features were added. |default-autocmds| • Treesitter: - • Bundled parsers and queries (highlight, folds) for Markdown, Python, and - Bash. + • Bundled parser and queries (highlight, folds) for Markdown (used for LSP + hover). • |:InspectTree| shows root nodes. • |:InspectTree| now supports |folding|. • |:InspectTree| shows node ranges in 0-based instead of 1-based indexing. diff --git a/runtime/doc/news-0.9.txt b/runtime/doc/news-0.9.txt index 7905d6c3e3..3b078cf2cd 100644 --- a/runtime/doc/news-0.9.txt +++ b/runtime/doc/news-0.9.txt @@ -92,7 +92,7 @@ The following new APIs or features were added. showing a text representation of the nodes in a language tree for the current buffer. -• |'statuscolumn'| option to customize the area to the side of a window, +• 'statuscolumn' option to customize the area to the side of a window, normally containing the fold, sign and number columns. This new option follows the 'statusline' syntax and can be used to transform the line numbers, create mouse click callbacks for |signs|, introduce a custom margin or separator etc. @@ -129,15 +129,17 @@ The following new APIs or features were added. • When using Nvim inside tmux 3.2 or later, the default clipboard provider will now copy to the system clipboard. |provider-clipboard| -• |'showcmdloc'| option to display the 'showcmd' information in the - status line or tab line. A new %S statusline item is available to place - the 'showcmd' text in a custom 'statusline'. Useful for when |'cmdheight'| - is set to 0. +• 'showcmdloc' option to display the 'showcmd' information in the status + line or tab line. A new %S statusline item is available to place the + 'showcmd' text in a custom 'statusline'. Useful for when 'cmdheight' is set + to 0. -• |'splitkeep'| option to control the scroll behavior of horizontal splits. +• 'splitkeep' option to control the scroll behavior of horizontal splits. -• |'diffopt'| now includes a `linematch` option to enable a second-stage diff - on individual hunks to provide much more accurate diffs. This option is also +• 'wildoptions' flag "fuzzy" enables |fuzzy-matching| during |cmdline-completion|. + +• 'diffopt' now includes a `linematch` option to enable a second-stage diff on + individual hunks to provide much more accurate diffs. This option is also available to |vim.diff()| See https://github.com/neovim/neovim/pull/14537. @@ -235,7 +237,7 @@ The following changes to existing APIs or features add new behavior. relative to the mouse. Note that the mouse doesn't update frequently without setting `vim.o.mousemoveevent = true` -• |nvim_eval_statusline()| supports evaluating the |'statuscolumn'| through a +• |nvim_eval_statusline()| supports evaluating the 'statuscolumn' through a new `opts` field: `use_statuscol_lnum`. • |nvim_buf_get_extmarks()| now accepts a -1 `ns_id` to request extmarks from diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 708e127136..ed5bd973be 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -18,6 +18,10 @@ BREAKING CHANGES IN HEAD *news-breaking-dev* The following changes to UNRELEASED features were made during the development cycle (Nvim HEAD, the "master" branch). +OPTIONS + +• 'jumpoptions' flag "unload" has been renamed to "clean". + ============================================================================== BREAKING CHANGES *news-breaking* @@ -25,20 +29,40 @@ These changes may require adaptations in your config or plugins. API +• Improved API "meta" docstrings and :help documentation. • `vim.rpcnotify(0)` and `rpcnotify(0)` broadcast to ALL channels. Previously they would "multicast" only to subscribed channels (controlled by `nvim_subscribe()`). Plugins and clients that want "multicast" behavior must now maintain their own list of channels. • In the future, |vim.rpcnotify()| may accept a list of channels, if there is demand for this use-case. +• "Dictionary" was renamed to "Dict" internally and in the RPC |api-metadata|. + This is not expected to break clients because there are no known clients + that actually use the `return_type` field or the parameter type names + reported by |--api-info| or |nvim_get_api_info()|. +• Renamed `nvim__id_dictionary` (unsupported/experimental API) to + `nvim__id_dict`. DEFAULTS -• TODO +• |]d-default| and |[d-default| accept a count. +• |[D-default| and |]D-default| jump to the first and last diagnostic in the + current buffer, respectively. + +DIAGNOSTICS + +• |vim.diagnostic.config()| accepts a "jump" table to specify defaults for + |vim.diagnostic.jump()|. EDITOR -• The order in which signs are placed was changed. Higher priority signs will now appear left of lower priority signs. +• The order in which signs are placed was changed. Higher priority signs will + now appear left of lower priority signs. +• |hl-CurSearch| now behaves the same as Vim and no longer updates on every + cursor movement. +• Moving in the buffer list using |:bnext| and similar commands behaves as + documented and skips help buffers if run from a non-help buffer, otherwise + it moves to another help buffer. EVENTS @@ -46,15 +70,26 @@ EVENTS LSP -• TODO +• Improved rendering of LSP hover docs. |K-lsp-default| +• |vim.lsp.completion.enable()| gained the `convert` callback which enables + customizing the transformation of an LSP CompletionItem to |complete-items|. +• |vim.lsp.diagnostic.from()| can be used to convert a list of + |vim.Diagnostic| objects into their LSP diagnostic representation. LUA -• TODO +• API functions now consistently return an empty dictionary as + |vim.empty_dict()|. Earlier, a |lua-special-tbl| was sometimes used. +• Command-line completions for: `vim.g`, `vim.t`, `vim.w`, `vim.b`, `vim.v`, + `vim.o`, `vim.wo`, `vim.bo`, `vim.opt`, `vim.opt_local`, `vim.opt_global`, + and `vim.fn`. OPTIONS -• TODO +• The 'statuscolumn' `%l` item can now be used as a number column segment that + changes according to related options. It takes care of alignment, 'number', + 'relativenumber' and 'signcolumn' set to "number". The now redundant `%r` item + is no longer treated specially for 'statuscolumn'. PLUGINS @@ -62,12 +97,28 @@ PLUGINS TREESITTER -• TODO +• |Query:iter_matches()| correctly returns all matching nodes in a match + instead of only the last node. This means that the returned table maps + capture IDs to a list of nodes that need to be iterated over. For + backwards compatibility, an option `all=false` (only return the last + matching node) is provided that will be removed in a future release. +• |vim.treesitter.language.get_filetypes()| always includes the {language} + argument in addition to explicitly registered filetypes. +• |vim.treesitter.language.get_lang()| falls back to the {filetype} argument + if no languages are explicitly registered. +• |vim.treesitter.language.add()| returns `true` if a parser was loaded + successfully and `nil,errmsg` otherwise instead of throwing an error. TUI • TODO +VIMSCRIPT + +• |v:msgpack_types| has the type "binary" removed. |msgpackparse()| no longer + treats BIN, STR and FIXSTR as separate types. Any of these is returned as a + string if possible, or a |blob| if the value contained embedded NUL:s. + ============================================================================== NEW FEATURES *news-features* @@ -75,35 +126,67 @@ The following new features were added. API -• TODO +• |nvim__ns_set()| can set properties for a namespace DEFAULTS -• Keymaps: - - |grn| in Normal mode maps to |vim.lsp.buf.rename()| - - |grr| in Normal mode maps to |vim.lsp.buf.references()| - - |gra| in Normal and Visual mode maps to |vim.lsp.buf.code_action()| - - CTRL-S in Insert mode maps to |vim.lsp.buf.signature_help()| +• Highlighting: + • Improved styling of :checkhealth and :help buffers. + +• Mappings: + • |grn| in Normal mode maps to |vim.lsp.buf.rename()| + • |grr| in Normal mode maps to |vim.lsp.buf.references()| + • |gra| in Normal and Visual mode maps to |vim.lsp.buf.code_action()| + • CTRL-S in Insert mode maps to |vim.lsp.buf.signature_help()| + • Mouse |popup-menu| includes an "Open in web browser" item when you right-click + on a URL. + • Mouse |popup-menu| includes a "Go to definition" item when LSP is active + in the buffer. + • Mappings inspired by Tim Pope's vim-unimpaired: + • |[q|, |]q|, |[Q|, |]Q|, |[CTRL-Q|, |]CTRL-Q| navigate through the |quickfix| list + • |[l|, |]l|, |[L|, |]L|, |[CTRL-L|, |]CTRL-L| navigate through the |location-list| + • |[t|, |]t|, |[T|, |]T|, |[CTRL-T|, |]CTRL-T| navigate through the |tag-matchlist| + • |[a|, |]a|, |[A|, |]A| navigate through the |argument-list| + • |[b|, |]b|, |[B|, |]B| navigate through the |buffer-list| + +• Snippet: + • `<Tab>` in Insert and Select mode maps to `vim.snippet.jump({ direction = 1 })` + when a snippet is active and jumpable forwards. + • `<S-Tab>` in Insert and Select mode maps to `vim.snippet.jump({ direction = -1 })` + when a snippet is active and jumpable backwards. EDITOR -• TODO +• Improved |paste| handling for redo (dot-repeat) and macros (|recording|): + • Redoing a large paste is significantly faster and ignores 'autoindent'. + • Replaying a macro with |@| also replays pasted text. +• On Windows, filename arguments on the command-line prefixed with "~\" or + "~/" are now expanded to the user's profile directory, not a relative path + to a literal "~" directory. +• |hl-PmenuMatch| and |hl-PmenuMatchSel| show matched text in completion popup. EVENTS -• TODO +• |CompleteDone| now sets the `reason` key in `v:event` which specifies the reason + for completion being done. LSP -• TODO +• Completion side effects (including snippet expansion, execution of commands + and application of additional text edits) is now built-in. +• |vim.lsp.util.locations_to_items()| sets `end_col` and `end_lnum` fields. +• |vim.lsp.buf.format()| now supports passing a list of ranges + via the `range` parameter (this requires support for the + `textDocument/rangesFormatting` request). LUA -• TODO +• |vim.fs.rm()| can delete files and directories. OPTIONS -• TODO +• 'completeopt' flag "fuzzy" enables |fuzzy-matching| during |ins-completion|. +• 'tabclose' controls which tab page to focus when closing a tab page. PERFORMANCE @@ -111,38 +194,65 @@ PERFORMANCE PLUGINS -• TODO +• EditorConfig + • spelling_language property is now supported. STARTUP -• TODO +• Nvim will fail if the |--listen| or |$NVIM_LISTEN_ADDRESS| address is + invalid, instead of silently skipping an invalid address. TERMINAL -• TODO +• The |terminal| now understands the OSC 52 escape sequence to write to the + system clipboard (copy). Querying with OSC 52 (paste) is not supported. +• |hl-StatusLineTerm| and |hl-StatusLineTermNC| define highlights for the + status line in |terminal| windows. +• The terminal buffer now supports reflow (wrapped lines adapt when the buffer + is resized horizontally). Note: Lines that are not visible and kept in + 'scrollback' are not reflown. +• The |terminal| now supports OSC 8 escape sequences and will display + hyperlinks in supporting host terminals. TREESITTER -• TODO +• |LanguageTree:node_for_range()| gets anonymous and named nodes for a range +• |vim.treesitter.get_node()| now takes an option `include_anonymous`, default + false, which allows it to return anonymous nodes as well as named nodes. TUI -• TODO +• The builtin UI declares info |nvim_set_client_info()| on its channel. See + |startup-tui|. To see the current UI info, try this: > + :lua =vim.api.nvim_get_chan_info(vim.api.nvim_list_uis()[1].chan) +• |log| messages written by the builtin UI client (TUI, |--remote-ui|) are + now prefixed with "ui" instead of "?". UI -• TODO - - -• |CompleteDone| now sets the `reason` key in `v:event` which specifies the reason - for completion being done. +• |vim.ui.open()| (by default bound to |gx|) accepts an `opt.cmd` parameter + which controls the tool used to open the given path or URL. If you want to + globally set this, you can override vim.ui.open using the same approach + described at |vim.paste()|. ============================================================================== CHANGED FEATURES *news-changed* These existing features changed their behavior. -• N/A +• 'scrollbind' now works properly with buffers that contain virtual lines. + + Scrollbind works by aligning to a target top line of each window in a tab + page. Previously this was done by calculating the difference between the old + top line and the target top line, and scrolling by that amount. Now the + top lines are calculated using screen line numbers which take virtual lines + into account. + +• The implementation of grapheme clusters (or combining chars |mbyte-combining|) + was upgraded to closely follow extended grapheme clusters as defined by UAX#29 + in the unicode standard. Noteworthily, this enables proper display of many + more emoji characters than before, including those encoded with multiple + emoji codepoints combined with ZWJ (zero width joiner) codepoints. ============================================================================== REMOVED FEATURES *news-removed* diff --git a/runtime/doc/nvim.txt b/runtime/doc/nvim.txt index ef407922da..f8eba3f7f8 100644 --- a/runtime/doc/nvim.txt +++ b/runtime/doc/nvim.txt @@ -4,7 +4,7 @@ NVIM REFERENCE MANUAL -Nvim *nvim* *nvim-intro* +Nvim *neovim* *nvim* *nvim-intro* Nvim is based on Vim by Bram Moolenaar. diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 5570e62ab8..6dd062124b 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -58,7 +58,8 @@ achieve special effects. These options come in three forms: :se[t] {option}:{value} Set string or number option to {value}. For numeric options the value can be given in decimal, - hex (preceded with 0x) or octal (preceded with '0'). + hex (preceded with 0x) or octal (preceded with '0' or + '0o'). The old value can be inserted by typing 'wildchar' (by default this is a <Tab>). Many string options with fixed syntax also support completing known values. @@ -332,13 +333,14 @@ between string and number-based options. options which are different from the default. For buffer-local and window-local options: - Command global value local value ~ - :set option=value set set - :setlocal option=value - set -:setglobal option=value set - - :set option? - display - :setlocal option? - display -:setglobal option? display - + Command global value local value condition ~ + :set option=value set set + :setlocal option=value - set +:setglobal option=value set - + :set option? - display local value is set + :set option? display - local value is not set + :setlocal option? - display +:setglobal option? display - Global options with a local value *global-local* @@ -383,15 +385,37 @@ the name, e.g. "<lambda>123". Examples: set opfunc=function('MyOpFunc') set opfunc=funcref('MyOpFunc') set opfunc={a\ ->\ MyOpFunc(a)} - " set using a funcref variable + +Set to a script-local function: > + set opfunc=s:MyLocalFunc + set opfunc=<SID>MyLocalFunc + +Set using a funcref variable: > let Fn = function('MyTagFunc') let &tagfunc = Fn - " set using a lambda expression + +Set using a lambda expression: > let &tagfunc = {t -> MyTagFunc(t)} - " set using a variable with lambda expression + +Set using a variable with lambda expression: > let L = {a, b, c -> MyTagFunc(a, b , c)} let &tagfunc = L -< + +Calling a function in an expr option *expr-option-function* + +The value of a few options, such as 'foldexpr', is an expression that is +evaluated to get a value. The evaluation can have quite a bit of overhead. +One way to minimize the overhead, and also to keep the option value very +simple, is to define a function and set the option to call it without +arguments. A |v:lua-call| can also be used. Example: >vim + lua << EOF + function _G.MyFoldFunc() + -- ... compute fold level for line v:lnum + return level + end + EOF + set foldexpr=v:lua.MyFoldFunc() + Setting the filetype @@ -1092,7 +1116,7 @@ A jump table for the options with a short description can be found at |Q_op|. applying 'breakindent', even if the resulting text should normally be narrower. This prevents text indented almost to the right window border - occupying lot of vertical space when broken. + occupying lots of vertical space when broken. (default: 20) shift:{n} After applying 'breakindent', the wrapped line's beginning will be shifted by the given number of @@ -1106,9 +1130,9 @@ A jump table for the options with a short description can be found at |Q_op|. list:{n} Adds an additional indent for lines that match a numbered or bulleted list (using the 'formatlistpat' setting). - list:-1 Uses the length of a match with 'formatlistpat' - for indentation. (default: 0) + list:-1 Uses the width of a match with 'formatlistpat' for + indentation. column:{n} Indent at column {n}. Will overrule the other sub-options. Note: an additional indent may be added for the 'showbreak' setting. @@ -1252,9 +1276,10 @@ A jump table for the options with a short description can be found at |Q_op|. The key used in Command-line Mode to open the command-line window. Only non-printable keys are allowed. The key can be specified as a single character, but it is difficult to - type. The preferred way is to use the <> notation. Examples: >vim - exe "set cedit=\<C-Y>" - exe "set cedit=\<Esc>" + type. The preferred way is to use |key-notation| (e.g. <Up>, <C-F>) or + a letter preceded with a caret (e.g. `^F` is CTRL-F). Examples: >vim + set cedit=^Y + set cedit=<Esc> < |Nvi| also has this option, but it only uses the first character. See |cmdwin|. @@ -1298,6 +1323,17 @@ A jump table for the options with a short description can be found at |Q_op|. v:fname_in name of the input file v:fname_out name of the output file Note that v:fname_in and v:fname_out will never be the same. + + The advantage of using a function call without arguments is that it is + faster, see |expr-option-function|. + + If the 'charconvert' expression starts with s: or |<SID>|, then it is + replaced with the script ID (|local-function|). Example: >vim + set charconvert=s:MyConvert() + set charconvert=<SID>SomeConvert() +< Otherwise the expression is evaluated in the context of the script + where the option was set, thus script-local items are available. + This option cannot be set from a |modeline| or in the |sandbox|, for security reasons. @@ -1388,11 +1424,10 @@ A jump table for the options with a short description can be found at |Q_op|. used. The command-line will cover the last line of the screen when shown. - WARNING: `cmdheight=0` is considered experimental. Expect some - unwanted behaviour. Some 'shortmess' flags and similar - mechanism might fail to take effect, causing unwanted hit-enter - prompts. Some informative messages, both from Nvim itself and - plugins, will not be displayed. + WARNING: `cmdheight=0` is EXPERIMENTAL. Expect some unwanted behaviour. + Some 'shortmess' flags and similar mechanism might fail to take effect, + causing unwanted hit-enter prompts. Some informative messages, both + from Nvim itself and plugins, will not be displayed. *'cmdwinheight'* *'cwh'* 'cmdwinheight' 'cwh' number (default 7) @@ -1442,8 +1477,8 @@ A jump table for the options with a short description can be found at |Q_op|. 'commentstring' 'cms' string (default "") local to buffer A template for a comment. The "%s" in the value is replaced with the - comment text. For example, C uses "/*%s*/". Used for |commenting| and to - add markers for folding, see |fold-marker|. + comment text, and should be padded with a space when possible. + Used for |commenting| and to add markers for folding, see |fold-marker|. *'complete'* *'cpt'* *E535* 'complete' 'cpt' string (default ".,w,b,u,t") @@ -1493,9 +1528,19 @@ A jump table for the options with a short description can be found at |Q_op|. This option cannot be set from a |modeline| or in the |sandbox|, for security reasons. + *'completeitemalign'* *'cia'* +'completeitemalign' 'cia' string (default "abbr,kind,menu") + global + A comma-separated list of |complete-items| that controls the alignment + and display order of items in the popup menu during Insert mode + completion. The supported values are abbr, kind, and menu. These + options allow to customize how the completion items are shown in the + popup menu. Note: must always contain those three values in any + order. + *'completeopt'* *'cot'* 'completeopt' 'cot' string (default "menu,preview") - global + global or local to buffer |global-local| A comma-separated list of options for Insert mode completion |ins-completion|. The supported values are: @@ -1517,6 +1562,10 @@ A jump table for the options with a short description can be found at |Q_op|. completion in the preview window. Only works in combination with "menu" or "menuone". + popup Show extra information about the currently selected + completion in a popup window. Only works in combination + with "menu" or "menuone". Overrides "preview". + noinsert Do not insert any text for a match until the user selects a match from the menu. Only works in combination with "menu" or "menuone". No effect if "longest" is present. @@ -1525,9 +1574,13 @@ A jump table for the options with a short description can be found at |Q_op|. select one from the menu. Only works in combination with "menu" or "menuone". - popup Show extra information about the currently selected - completion in a popup window. Only works in combination - with "menu" or "menuone". Overrides "preview". + fuzzy Enable |fuzzy-matching| for completion candidates. This + allows for more flexible and intuitive matching, where + characters can be skipped and matches can be found even + if the exact sequence is not typed. Only makes a + difference how completion candidates are reduced from the + list of alternatives, but not how the candidates are + collected (using different completion types). *'completeslash'* *'csl'* 'completeslash' 'csl' string (default "") @@ -2175,9 +2228,12 @@ A jump table for the options with a short description can be found at |Q_op|. global When on all Unicode emoji characters are considered to be full width. This excludes "text emoji" characters, which are normally displayed as - single width. Unfortunately there is no good specification for this - and it has been determined on trial-and-error basis. Use the - |setcellwidths()| function to change the behavior. + single width. However, such "text emoji" are treated as full-width + emoji if they are followed by the U+FE0F variant selector. + + Unfortunately there is no good specification for this and it has been + determined on trial-and-error basis. Use the |setcellwidths()| + function to change the behavior. *'encoding'* *'enc'* 'encoding' 'enc' string (default "utf-8") @@ -2483,14 +2539,14 @@ A jump table for the options with a short description can be found at |Q_op|. /* vim: set filetype=idl : */ < |FileType| |filetypes| When a dot appears in the value then this separates two filetype - names. Example: >c + names, it should therefore not be used for a filetype. Example: >c /* vim: set filetype=c.doxygen : */ < This will use the "c" filetype first, then the "doxygen" filetype. This works both for filetype plugins and for syntax files. More than one dot may appear. This option is not copied to another buffer, independent of the 's' or 'S' flag in 'cpoptions'. - Only normal file name characters can be used, `/\*?[|<>` are illegal. + Only alphanumeric characters, '-' and '_' can be used. *'fillchars'* *'fcs'* 'fillchars' 'fcs' string (default "") @@ -2749,6 +2805,9 @@ A jump table for the options with a short description can be found at |Q_op|. < This will invoke the mylang#Format() function in the autoload/mylang.vim file in 'runtimepath'. |autoload| + The advantage of using a function call without arguments is that it is + faster, see |expr-option-function|. + The expression is also evaluated when 'textwidth' is set and adding text beyond that limit. This happens under the same conditions as when internal formatting is used. Make sure the cursor is kept in the @@ -3384,11 +3443,14 @@ A jump table for the options with a short description can be found at |Q_op|. If the expression starts with s: or |<SID>|, then it is replaced with the script ID (|local-function|). Example: >vim - setlocal includeexpr=s:MyIncludeExpr(v:fname) - setlocal includeexpr=<SID>SomeIncludeExpr(v:fname) + setlocal includeexpr=s:MyIncludeExpr() + setlocal includeexpr=<SID>SomeIncludeExpr() < Otherwise, the expression is evaluated in the context of the script where the option was set, thus script-local items are available. + It is more efficient if the value is just a function call without + arguments, see |expr-option-function|. + The expression will be evaluated in the |sandbox| when set from a modeline, see |sandbox-option|. This option cannot be set in a modeline when 'modelineexpr' is off. @@ -3439,7 +3501,7 @@ A jump table for the options with a short description can be found at |Q_op|. in Insert mode as specified with the 'indentkeys' option. When this option is not empty, it overrules the 'cindent' and 'smartindent' indenting. When 'lisp' is set, this option is - is only used when 'lispoptions' contains "expr:1". + only used when 'lispoptions' contains "expr:1". The expression is evaluated with |v:lnum| set to the line number for which the indent is to be computed. The cursor is also in this line when the expression is evaluated (but it may be moved around). @@ -3451,6 +3513,9 @@ A jump table for the options with a short description can be found at |Q_op|. < Otherwise, the expression is evaluated in the context of the script where the option was set, thus script-local items are available. + The advantage of using a function call without arguments is that it is + faster, see |expr-option-function|. + The expression must return the number of spaces worth of indent. It can return "-1" to keep the current indent (this means 'autoindent' is used for the indent). @@ -3611,7 +3676,7 @@ A jump table for the options with a short description can be found at |Q_op|. Otherwise only one space is inserted. *'jumpoptions'* *'jop'* -'jumpoptions' 'jop' string (default "") +'jumpoptions' 'jop' string (default "clean") global List of words that change the behavior of the |jumplist|. stack Make the jumplist behave like the tagstack. @@ -3624,6 +3689,9 @@ A jump table for the options with a short description can be found at |Q_op|. |alternate-file| or using |mark-motions| try to restore the |mark-view| in which the action occurred. + clean Remove unloaded buffers from the jumplist. + EXPERIMENTAL: this flag may change in the future. + *'keymap'* *'kmp'* 'keymap' 'kmp' string (default "") local to buffer @@ -3631,7 +3699,7 @@ A jump table for the options with a short description can be found at |Q_op|. Setting this option to a valid keymap name has the side effect of setting 'iminsert' to one, so that the keymap becomes effective. 'imsearch' is also set to one, unless it was -1 - Only normal file name characters can be used, `/\*?[|<>` are illegal. + Only alphanumeric characters, '.', '-' and '_' can be used. *'keymodel'* *'km'* 'keymodel' 'km' string (default "") @@ -3688,7 +3756,7 @@ A jump table for the options with a short description can be found at |Q_op|. part can be in one of two forms: 1. A list of pairs. Each pair is a "from" character immediately followed by the "to" character. Examples: "aA", "aAbBcC". - 2. A list of "from" characters, a semi-colon and a list of "to" + 2. A list of "from" characters, a semicolon and a list of "to" characters. Example: "abc;ABC" Example: "aA,fgh;FGH,cCdDeE" Special characters need to be preceded with a backslash. These are @@ -3756,7 +3824,7 @@ A jump table for the options with a short description can be found at |Q_op|. update use |:redraw|. This may occasionally cause display errors. It is only meant to be set temporarily when performing an operation where redrawing may cause - flickering or cause a slow down. + flickering or cause a slowdown. *'linebreak'* *'lbr'* *'nolinebreak'* *'nolbr'* 'linebreak' 'lbr' boolean (default off) @@ -3834,6 +3902,9 @@ A jump table for the options with a short description can be found at |Q_op|. between tabs and spaces and for trailing blanks. Further changed by the 'listchars' option. + When 'listchars' does not contain "tab" field, tabs are shown as "^I" + or "<09>", like how unprintable characters are displayed. + The cursor is displayed at the start of the space a Tab character occupies, not at the end as usual in Normal mode. To get this cursor position while displaying Tabs with spaces, use: >vim @@ -4416,6 +4487,20 @@ A jump table for the options with a short description can be found at |Q_op|. (without "unsigned" it would become "9-2019"). Using CTRL-X on "0" or CTRL-A on "18446744073709551615" (2^64 - 1) has no effect, overflow is prevented. + blank If included, treat numbers as signed or unsigned based on + preceding whitespace. If a number with a leading dash has its + dash immediately preceded by a non-whitespace character (i.e., + not a tab or a " "), the negative sign won't be considered as + part of the number. For example: + Using CTRL-A on "14" in "Carbon-14" results in "Carbon-15" + (without "blank" it would become "Carbon-13"). + Using CTRL-X on "8" in "Carbon -8" results in "Carbon -9" + (because -8 is preceded by whitespace. If "unsigned" was + set, it would result in "Carbon -7"). + If this format is included, overflow is prevented as if + "unsigned" were set. If both this format and "unsigned" are + included, "unsigned" will take precedence. + Numbers which simply begin with a digit in the range 1-9 are always considered decimal. This also happens for numbers that are not recognized as octal or hex. @@ -4582,7 +4667,7 @@ A jump table for the options with a short description can be found at |Q_op|. set path+= < To use an environment variable, you probably need to replace the separator. Here is an example to append $INCL, in which directory - names are separated with a semi-colon: >vim + names are separated with a semicolon: >vim let &path = &path .. "," .. substitute($INCL, ';', ',', 'g') < Replace the ';' with a ':' or whatever separator is used. Note that this doesn't work when $INCL contains a comma or white space. @@ -4960,6 +5045,9 @@ A jump table for the options with a short description can be found at |Q_op|. Minimum is 1, maximum is 100000. Only in |terminal| buffers. + Note: Lines that are not visible and kept in scrollback are not + reflown when the terminal buffer is resized horizontally. + *'scrollbind'* *'scb'* *'noscrollbind'* *'noscb'* 'scrollbind' 'scb' boolean (default off) local to window @@ -5442,7 +5530,7 @@ A jump table for the options with a short description can be found at |Q_op|. 'shortmess' 'shm' string (default "ltToOCF") global This option helps to avoid all the |hit-enter| prompts caused by file - messages, for example with CTRL-G, and to avoid some other messages. + messages, for example with CTRL-G, and to avoid some other messages. It is a list of flags: flag meaning when present ~ l use "999L, 888B" instead of "999 lines, 888 bytes" *shm-l* @@ -5459,8 +5547,8 @@ A jump table for the options with a short description can be found at |Q_op|. message; also for quickfix message (e.g., ":cn") s don't give "search hit BOTTOM, continuing at TOP" or *shm-s* "search hit TOP, continuing at BOTTOM" messages; when using - the search count do not show "W" after the count message (see - S below) + the search count do not show "W" before the count message + (see |shm-S| below) t truncate file message at the start if it is too long *shm-t* to fit on the command-line, "<" will appear in the left most column; ignored in Ex mode @@ -5482,7 +5570,11 @@ A jump table for the options with a short description can be found at |Q_op|. `:silent` was used for the command; note that this also affects messages from 'autoread' reloading S do not show search count message when searching, e.g. *shm-S* - "[1/5]" + "[1/5]". When the "S" flag is not present (e.g. search count + is shown), the "search hit BOTTOM, continuing at TOP" and + "search hit TOP, continuing at BOTTOM" messages are only + indicated by a "W" (Mnemonic: Wrapped) letter before the + search count statistics. This gives you the opportunity to avoid that a change between buffers requires you to hit <Enter>, but still gives as useful a message as @@ -5847,7 +5939,7 @@ A jump table for the options with a short description can be found at |Q_op|. minus two. timeout:{millisec} Limit the time searching for suggestions to - {millisec} milli seconds. Applies to the following + {millisec} milliseconds. Applies to the following methods. When omitted the limit is 5000. When negative there is no limit. @@ -5867,9 +5959,11 @@ A jump table for the options with a short description can be found at |Q_op|. The file is used for all languages. expr:{expr} Evaluate expression {expr}. Use a function to avoid - trouble with spaces. |v:val| holds the badly spelled - word. The expression must evaluate to a List of - Lists, each with a suggestion and a score. + trouble with spaces. Best is to call a function + without arguments, see |expr-option-function|. + |v:val| holds the badly spelled word. The expression + must evaluate to a List of Lists, each with a + suggestion and a score. Example: [['the', 33], ['that', 44]] ~ Set 'verbose' and use |z=| to see the scores that the @@ -5921,7 +6015,8 @@ A jump table for the options with a short description can be found at |Q_op|. non-blank of the line. When off the cursor is kept in the same column (if possible). This applies to the commands: - CTRL-D, CTRL-U, CTRL-B, CTRL-F, "G", "H", "M", "L", "gg" - - "d", "<<" and ">>" with a linewise operator + - "d", "<<", "==" and ">>" with a linewise operator + (|operator-resulting-pos|) - "%" with a count - buffer changing commands (CTRL-^, :bnext, :bNext, etc.) - Ex commands that only have a line number, e.g., ":25" or ":+". @@ -5931,7 +6026,6 @@ A jump table for the options with a short description can be found at |Q_op|. *'statuscolumn'* *'stc'* 'statuscolumn' 'stc' string (default "") local to window - EXPERIMENTAL When non-empty, this option determines the content of the area to the side of a window, normally containing the fold, sign and number columns. The format of this option is like that of 'statusline'. @@ -5939,8 +6033,7 @@ A jump table for the options with a short description can be found at |Q_op|. Some of the items from the 'statusline' format are different for 'statuscolumn': - %l line number of currently drawn line - %r relative line number of currently drawn line + %l line number column for currently drawn line %s sign column for currently drawn line %C fold column for currently drawn line @@ -5967,11 +6060,8 @@ A jump table for the options with a short description can be found at |Q_op|. handler should be written with this in mind. Examples: >vim - " Relative number with bar separator and click handlers: - set statuscolumn=%@SignCb@%s%=%T%@NumCb@%r│%T - - " Right aligned relative cursor line number: - let &stc='%=%{v:relnum?v:relnum:v:lnum} ' + " Line number with bar separator and click handlers: + set statuscolumn=%@SignCb@%s%=%T%@NumCb@%l│%T " Line numbers in hexadecimal for non wrapped part of lines: let &stc='%=%{v:virtnum>0?"":printf("%x",v:lnum)} ' @@ -6313,7 +6403,20 @@ A jump table for the options with a short description can be found at |Q_op|. Syntax autocommand event is triggered with the value as argument. This option is not copied to another buffer, independent of the 's' or 'S' flag in 'cpoptions'. - Only normal file name characters can be used, `/\*?[|<>` are illegal. + Only alphanumeric characters, '.', '-' and '_' can be used. + + *'tabclose'* *'tcl'* +'tabclose' 'tcl' string (default "") + global + This option controls the behavior when closing tab pages (e.g., using + |:tabclose|). When empty Vim goes to the next (right) tab page. + + Possible values (comma-separated list): + left If included, go to the previous tab page instead of + the next one. + uselast If included, go to the previously used tab page if + possible. This option takes precedence over the + others. *'tabline'* *'tal'* 'tabline' 'tal' string (default "") @@ -6621,7 +6724,7 @@ A jump table for the options with a short description can be found at |Q_op|. global When on, the title of the window will be set to the value of 'titlestring' (if it is not empty), or to: - filename [+=-] (path) - NVIM + filename [+=-] (path) - Nvim Where: filename the name of the file being edited - indicates the file cannot be modified, 'ma' off @@ -6629,7 +6732,7 @@ A jump table for the options with a short description can be found at |Q_op|. = indicates the file is read-only =+ indicates the file is read-only and modified (path) is the path of the file being edited - - NVIM the server name |v:servername| or "NVIM" + - Nvim the server name |v:servername| or "Nvim" *'titlelen'* 'titlelen' number (default 85) @@ -7022,7 +7125,12 @@ A jump table for the options with a short description can be found at |Q_op|. Some keys will not work, such as CTRL-C, <CR> and Enter. <Esc> can be used, but hitting it twice in a row will still exit command-line as a failsafe measure. - Although 'wc' is a number option, you can set it to a special key: >vim + Although 'wc' is a number option, it can be specified as a number, a + single character, a |key-notation| (e.g. <Up>, <C-F>) or a letter + preceded with a caret (e.g. `^F` is CTRL-F): >vim + :set wc=27 + :set wc=X + :set wc=^I set wc=<Tab> < diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt index 1ef182127c..8ec02276cc 100644 --- a/runtime/doc/pattern.txt +++ b/runtime/doc/pattern.txt @@ -141,13 +141,17 @@ CTRL-C Interrupt current (search) command. executing autocommands |autocmd-searchpat|. Same thing for when invoking a user function. + While typing the search pattern the current match will be shown if the 'incsearch' option is on. Remember that you still have to finish the search command with <CR> to actually position the cursor at the displayed match. Or use <Esc> to abandon the search. + *nohlsearch-auto* All matches for the last used search pattern will be highlighted if you set -the 'hlsearch' option. This can be suspended with the |:nohlsearch| command. +the 'hlsearch' option. This can be suspended with the |:nohlsearch| command +or auto suspended with nohlsearch plugin. See |nohlsearch-install|. + When 'shortmess' does not include the "S" flag, Vim will automatically show an index, on which the cursor is. This can look like this: > @@ -1494,5 +1498,7 @@ the matching positions and the fuzzy match scores. The "f" flag of `:vimgrep` enables fuzzy matching. +To enable fuzzy matching for |ins-completion|, add the "fuzzy" value to the +'completeopt' option. vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/runtime/doc/pi_netrw.txt b/runtime/doc/pi_netrw.txt index 81acd9cf7e..0652fb27e7 100644 --- a/runtime/doc/pi_netrw.txt +++ b/runtime/doc/pi_netrw.txt @@ -3858,7 +3858,7 @@ netrw: netrw-safe guioptions Nov 15, 2021 * removed netrw_localrm and netrw_localrmdir references - Aug 18, 2022 * (Miguel Barro) improving compatability with + Aug 18, 2022 * (Miguel Barro) improving compatibility with powershell v171: Oct 09, 2020 * included code in s:NetrwOptionsSafe() to allow |'bh'| to be set to delete when diff --git a/runtime/doc/provider.txt b/runtime/doc/provider.txt index a39f4bc5d7..f1b0daee76 100644 --- a/runtime/doc/provider.txt +++ b/runtime/doc/provider.txt @@ -194,6 +194,8 @@ registers. Nvim looks for these clipboard tools, in order of priority: - lemonade (for SSH) https://github.com/pocke/lemonade - doitclient (for SSH) https://www.chiark.greenend.org.uk/~sgtatham/doit/ - win32yank (Windows) + - putclip, getclip (Windows) https://cygwin.com/packages/summary/cygutils.html + - clip, powershell (Windows) https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/clip - termux (via termux-clipboard-set, termux-clipboard-set) - tmux (if $TMUX is set) @@ -248,8 +250,8 @@ For Windows WSL, try this g:clipboard definition: \ '*': 'clip.exe', \ }, \ 'paste': { - \ '+': 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))', - \ '*': 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))', + \ '+': 'powershell.exe -NoLogo -NoProfile -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))', + \ '*': 'powershell.exe -NoLogo -NoProfile -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))', \ }, \ 'cache_enabled': 0, \ } diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt index 5d3c0cbdc2..63109bdaf3 100644 --- a/runtime/doc/quickfix.txt +++ b/runtime/doc/quickfix.txt @@ -91,24 +91,24 @@ processing a quickfix or location list command, it will be aborted. :ll[!] [nr] Same as ":cc", except the location list for the :[nr]ll[!] current window is used instead of the quickfix list. - *:cn* *:cne* *:cnext* *E553* + *:cn* *:cne* *:cnext* *E553* *]q* :[count]cn[ext][!] Display the [count] next error in the list that includes a file name. If there are no file names at all, go to the [count] next error. See |:cc| for [!] and 'switchbuf'. - *:lne* *:lnext* + *:lne* *:lnext* *]l* :[count]lne[xt][!] Same as ":cnext", except the location list for the current window is used instead of the quickfix list. -:[count]cN[ext][!] *:cp* *:cprevious* *:cprev* *:cN* *:cNext* +:[count]cN[ext][!] *:cp* *:cprevious* *:cprev* *:cN* *:cNext* *[q* :[count]cp[revious][!] Display the [count] previous error in the list that includes a file name. If there are no file names at all, go to the [count] previous error. See |:cc| for [!] and 'switchbuf'. -:[count]lN[ext][!] *:lp* *:lprevious* *:lprev* *:lN* *:lNext* +:[count]lN[ext][!] *:lp* *:lprevious* *:lprev* *:lN* *:lNext* *[l* :[count]lp[revious][!] Same as ":cNext" and ":cprevious", except the location list for the current window is used instead of the quickfix list. @@ -171,18 +171,18 @@ processing a quickfix or location list command, it will be aborted. :[count]laf[ter] Same as ":cafter", except the location list for the current window is used instead of the quickfix list. - *:cnf* *:cnfile* + *:cnf* *:cnfile* *]CTRL-Q* :[count]cnf[ile][!] Display the first error in the [count] next file in the list that includes a file name. If there are no file names at all or if there is no next file, go to the [count] next error. See |:cc| for [!] and 'switchbuf'. - *:lnf* *:lnfile* + *:lnf* *:lnfile* *]CTRL-L* :[count]lnf[ile][!] Same as ":cnfile", except the location list for the current window is used instead of the quickfix list. -:[count]cNf[ile][!] *:cpf* *:cpfile* *:cNf* *:cNfile* +:[count]cNf[ile][!] *:cpf* *:cpfile* *:cNf* *:cNfile* *[CTRL-Q* :[count]cpf[ile][!] Display the last error in the [count] previous file in the list that includes a file name. If there are no file names at all or if there is no next file, go to @@ -190,16 +190,16 @@ processing a quickfix or location list command, it will be aborted. 'switchbuf'. -:[count]lNf[ile][!] *:lpf* *:lpfile* *:lNf* *:lNfile* +:[count]lNf[ile][!] *:lpf* *:lpfile* *:lNf* *:lNfile* *[CTRL-L* :[count]lpf[ile][!] Same as ":cNfile" and ":cpfile", except the location list for the current window is used instead of the quickfix list. - *:crewind* *:cr* + *:crewind* *:cr* *[Q* :cr[ewind][!] [nr] Display error [nr]. If [nr] is omitted, the FIRST error is displayed. See |:cc|. - *:lrewind* *:lr* + *:lrewind* *:lr* *[L* :lr[ewind][!] [nr] Same as ":crewind", except the location list for the current window is used instead of the quickfix list. @@ -209,11 +209,11 @@ processing a quickfix or location list command, it will be aborted. *:lfirst* *:lfir* :lfir[st][!] [nr] Same as ":lrewind". - *:clast* *:cla* + *:clast* *:cla* *]Q* :cla[st][!] [nr] Display error [nr]. If [nr] is omitted, the LAST error is displayed. See |:cc|. - *:llast* *:lla* + *:llast* *:lla* *]L* :lla[st][!] [nr] Same as ":clast", except the location list for the current window is used instead of the quickfix list. @@ -994,7 +994,7 @@ Another option is using 'makeencoding'. ============================================================================== 5. Using :vimgrep and :grep *grep* *lid* -Vim has two ways to find matches for a pattern: Internal and external. The +Vim has two ways to find matches for a pattern: internal and external. The advantage of the internal grep is that it works on all systems and uses the powerful Vim search patterns. An external grep program can be used when the Vim grep does not do what you want. @@ -1023,7 +1023,7 @@ commands can be combined to create a NewGrep command: > command! -nargs=+ NewGrep execute 'silent grep! <args>' | copen 42 -5.1 using Vim's internal grep +5.1 Using Vim's internal grep *:vim* *:vimgrep* *E682* *E683* :vim[grep][!] /{pattern}/[g][j][f] {file} ... @@ -1080,8 +1080,8 @@ commands can be combined to create a NewGrep command: > :vim[grep][!] {pattern} {file} ... Like above, but instead of enclosing the pattern in a - non-ID character use a white-separated pattern. The - pattern must start with an ID character. + non-ID character use a white space separated pattern. + The pattern must start with an ID character. Example: > :vimgrep Error *.c < @@ -1262,6 +1262,33 @@ not "b:current_compiler". What the command actually does is the following: For writing a compiler plugin, see |write-compiler-plugin|. +Use the |compiler-make| plugin to undo the effect of a compiler plugin. + +CPPCHECK *quickfix-cppcheck* *compiler-cppcheck* + +Use g/b:`c_cppcheck_params` to set cppcheck parameters. The global +settings by default include + +- `--verbose`: Enables verbose output. +- `--force`: Forces checking of all configurations. +- `--inline-suppr`: Allows inline suppressions. +- `--enable=...`: Enables specific checks like warnings, style, performance, + portability, information, and missing includes. +- `-j`: Utilizes multiple processors if available, determined by the + `getconf` command if available (requires omitting the unusedFunction check) + +For C++ files (`filetype == 'cpp'`), the `--language=c++` option is added to +ensure Cppcheck treats the file as C++. + +If compile_commands.json is present in the current directory, it is added as a +`--project` parameter to the command line. Otherwise, by default the +directories in &path are passed as include directories. These can be set by +g/b:`c_cppcheck_includes` as a list of `-I` flags. Tim Pope's vim-apathy +plug-in [0] can expand &path. To also append the folders in a git repo use > + + let &l:path = join(systemlist('git ls-tree -d --name-only -r HEAD'), ',') + +[0] https://github.com/tpope/vim-apathy DOTNET *compiler-dotnet* @@ -1277,7 +1304,6 @@ Example: limit output to only display errors, and suppress the project name: > let dotnet_show_project_file = v:false compiler dotnet < - GCC *quickfix-gcc* *compiler-gcc* There's one variable you can set for the GCC compiler: @@ -1288,6 +1314,31 @@ g:compiler_gcc_ignore_unmatched_lines commands run from make are generating false positives. +JAVAC *compiler-javac* + +Commonly used compiler options can be added to 'makeprg' by setting the +g:javac_makeprg_params variable. For example: > + let g:javac_makeprg_params = "-Xlint:all -encoding utf-8" +< +GNU MAKE *compiler-make* + +Since the default make program is "make", the compiler plugin for make, +:compiler make, will reset the 'makeprg' and 'errorformat' option to +the default values and unlet any variables that may have been set by a +previous compiler plugin. + +GROFF *quickfix-groff* *compiler-groff* + +The GROFF compiler plugin uses the mom macro set (documented in the groff_mom +manpage) as input and expects that the output file type extension is passed to +make, say :make html or :make pdf. + +Additional arguments can be passed to groff by setting them in +`b:groff_compiler_args` or `g:groff_compiler_args`. The `language` argument +passed to groff is set using 'spelllang'; it can be overridden by setting +`b:groff_compiler_lang`. The default encoding is `UTF-8` and can be changed +by setting `b:groff_compiler_encoding` or `g:groff_compiler_encoding`. + PANDOC *quickfix-pandoc* *compiler-pandoc* The Pandoc compiler plugin expects that an output file type extension is @@ -1296,7 +1347,13 @@ passed to make, say :make html or :make pdf. Additional arguments can be passed to pandoc: - either by appending them to make, say `:make html --self-contained` . -- or setting them in `b:pandoc_compiler_args` or `g:pandoc_compiler_args` +- or setting them in `b:pandoc_compiler_args` or `g:pandoc_compiler_args`. + +The `--from` argument is an educated guess using the buffer file type; +it can be overridden by setting `b:pandoc_compiler_from`. +The `--metadata lang` argument is set using 'spelllang'; +If `--from=markdown` is assumed and no title set in a title header or +YAML block, then the filename (without extension) is used as the title. PERL *quickfix-perl* *compiler-perl* @@ -1365,6 +1422,17 @@ shells and OSes and also does not allow to use other available TeX options, if any. If your TeX doesn't support "-interaction=nonstopmode", please report it with different means to express \nonstopmode from the command line. +TYPST COMPILER *compiler-typst* + +Vim includes a compiler plugin for Typst files. This compiler is enabled +automatically in Typst buffers by the Typst filetype plugin |ft-typst-plugin|. +Run |:make| to compile the current Typst file. + + *g:typst_cmd* +By default Vim will use "typst" as the command to run the Typst compiler. This +can be changed by setting the |g:typst_cmd| variable: > + let g:typst_cmd = "/path/to/other/command" + ============================================================================= 7. The error format *error-file-format* diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt index c0d00d16cb..d77750b485 100644 --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -886,6 +886,7 @@ Short explanation of each option: *option-list* 'switchbuf' 'swb' sets behavior when switching to another buffer 'synmaxcol' 'smc' maximum column to find syntax items 'syntax' 'syn' syntax to be loaded for current buffer +'tabclose' 'tcl' which tab page to focus when closing a tab 'tabline' 'tal' custom format for the console tab pages line 'tabpagemax' 'tpm' maximum number of tab pages for |-p| and "tab all" 'tabstop' 'ts' number of spaces that <Tab> in file uses @@ -898,6 +899,7 @@ Short explanation of each option: *option-list* 'tagstack' 'tgst' push tags onto the tag stack 'term' name of the terminal 'termbidi' 'tbidi' terminal takes care of bi-directionality +'termguicolors' 'tgc' enable 24-bit RGB color in the TUI 'textwidth' 'tw' maximum width of text that is being inserted 'thesaurus' 'tsr' list of thesaurus files for keyword completion 'thesaurusfunc' 'tsrfu' function to be used for thesaurus completion diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index 2263b20d1a..521d690d93 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -96,9 +96,9 @@ where the cursor was before the global command). The global command sets both the last used search pattern and the last used substitute pattern (this is vi compatible). This makes it easy to globally -replace a string: +replace a string: > :g/pat/s//PAT/g -This replaces all occurrences of "pat" with "PAT". The same can be done with: +This replaces all occurrences of "pat" with "PAT". The same can be done with: > :%s/pat/PAT/g Which is two characters shorter! @@ -447,7 +447,7 @@ Example: the lines > \:%, \n:>, \fb:- -are interpreted as if they were given in one line: +are interpreted as if they were given in one line: > :set comments=sr:/*,mb:*,el:*/,://,b:#,:%,n:>,fb:- All leading whitespace characters in the line before a backslash are ignored. @@ -540,7 +540,7 @@ the runtime path. Example: > Using a package and loading automatically ~ Let's assume your Nvim files are in "~/.local/share/nvim/site" and you want to -add a package from a zip archive "/tmp/foopack.zip": +add a package from a zip archive "/tmp/foopack.zip": > % mkdir -p ~/.local/share/nvim/site/pack/foo % cd ~/.local/share/nvim/site/pack/foo % unzip /tmp/foopack.zip @@ -589,7 +589,7 @@ If the package has an "after" directory, that directory is added to the end of Using a single plugin and loading it automatically ~ If you don't have a package but a single plugin, you need to create the extra -directory level: +directory level: > % mkdir -p ~/.local/share/nvim/site/pack/foo/start/foobar % cd ~/.local/share/nvim/site/pack/foo/start/foobar % unzip /tmp/someplugin.zip diff --git a/runtime/doc/scroll.txt b/runtime/doc/scroll.txt index 29d6177213..8b727a86fb 100644 --- a/runtime/doc/scroll.txt +++ b/runtime/doc/scroll.txt @@ -43,6 +43,8 @@ CTRL-D Scroll window Downwards in the buffer. The number of <S-Down> or *<S-Down>* *<kPageDown>* <PageDown> or *<PageDown>* *CTRL-F* +<S-CR> or *<S-CR>* *<S-NL>* +<S-+> or *SHIFT-+* *<S-Plus>* CTRL-F Scroll window [count] pages Forwards (downwards) in the buffer. See also 'startofline' option. When there is only one window the 'window' option @@ -80,6 +82,7 @@ CTRL-U Scroll window Upwards in the buffer. The number of <S-Up> or *<S-Up>* *<kPageUp>* <PageUp> or *<PageUp>* *CTRL-B* +<S--> or *<S-Minus>* *SHIFT-MINUS* CTRL-B Scroll window [count] pages Backwards (upwards) in the buffer. See also 'startofline' option. When there is only one window the 'window' option diff --git a/runtime/doc/sign.txt b/runtime/doc/sign.txt index 6fa260be40..9d74f1f376 100644 --- a/runtime/doc/sign.txt +++ b/runtime/doc/sign.txt @@ -67,15 +67,13 @@ sign group allows Vim plugins to use unique signs without interfering with other plugins using signs. *sign-priority* -Each placed sign is assigned a priority value. When multiple signs are placed -on the same line, the attributes of the sign with the highest priority is used -independently of the sign group. The default priority for a sign is 10. The -priority is assigned at the time of placing a sign. - -When multiple signs that each have an icon or text are present, signs are -ordered with increasing priority from left to right, up until the maximum -width set in 'signcolumn'. Lower priority signs that do not fit are hidden. -Highest priority signs with highlight attributes are always shown. +Each placed sign is assigned a priority value independently of the sign group. +The default priority for a sign is 10, this value can be changed for different +signs by specifying a different value at definition time. When multiple signs +that each have an icon or text are placed on the same line, signs are ordered +with decreasing priority from left to right, up until the maximum width set in +'signcolumn'. Low priority signs that do not fit are hidden. Highest priority +signs with highlight attributes are always shown. When the line on which the sign is placed is deleted, the sign is removed along with it. @@ -116,6 +114,9 @@ See |sign_define()| for the equivalent Vim script function. toolkit supports ~ Win32 .bmp, .ico, .cur + priority={prio} + Default priority for the sign, see |sign-priority|. + linehl={group} Highlighting group used for the whole line the sign is placed in. Most useful is defining a background color. @@ -186,11 +187,11 @@ See |sign_place()| for the equivalent Vim script function. By default, the sign is placed in the global sign group. - By default, the sign is assigned a default priority of 10. To - assign a different priority value, use "priority={prio}" to - specify a value. The priority is used to determine the sign - that is displayed when multiple signs are placed on the same - line. + By default, the sign is assigned a default priority of 10, + unless specified otherwise by the sign definition. To assign a + different priority value, use "priority={prio}" to specify a + value. The priority is used to determine the sign that is + displayed when multiple signs are placed on the same line. Examples: > :sign place 5 line=3 name=sign1 file=a.py diff --git a/runtime/doc/spell.txt b/runtime/doc/spell.txt index 269d52352d..a13bf079e8 100644 --- a/runtime/doc/spell.txt +++ b/runtime/doc/spell.txt @@ -776,7 +776,7 @@ them before the Vim word list is made. The tools for this can be found in the The format for the affix and word list files is based on what Myspell uses (the spell checker of Mozilla and OpenOffice.org). A description can be found here: - https://lingucomponent.openoffice.org/affix.readme ~ + https://lingucomponent.openoffice.org/affix.readme Note that affixes are case sensitive, this isn't obvious from the description. Vim supports quite a few extras. They are described below |spell-affix-vim|. diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index fb8ed0344b..3b0fa2b371 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -422,6 +422,10 @@ argument. Start |RPC| server on pipe or TCP address {addr}. Sets the primary listen address |v:servername| to {addr}. |serverstart()| + To start the server on-demand with systemd, use a systemd + socket unit and associated service unit running: > + systemd-socket-proxyd --exit-idle-time +< ============================================================================== Initialization *initialization* *startup* diff --git a/runtime/doc/support.txt b/runtime/doc/support.txt index 5b8b32fa16..0ddf037fba 100644 --- a/runtime/doc/support.txt +++ b/runtime/doc/support.txt @@ -12,9 +12,9 @@ Support *support* Supported platforms *supported-platforms* `System` `Tier` `Versions` `Tested versions` -Linux 1 >= 2.6.32, glibc >= 2.12 Ubuntu 22.04 +Linux 1 >= 2.6.32, glibc >= 2.12 Ubuntu 24.04 macOS (Intel) 1 >= 11 macOS 12 -macOS (M1) 2 >= 11 macOS 14 +macOS (M1) 1 >= 11 macOS 15 Windows 64-bit 1 >= Windows 10 Version 1809 Windows Server 2022 FreeBSD 1 >= 10 FreeBSD 13 OpenBSD 2 >= 7 @@ -25,13 +25,16 @@ Note: Windows 10 "Version 1809" or later is required for |:terminal|. To check your Windows version, run the "winver" command and look for "Version xxxx" (NOT "OS Build"). +Note: On Windows "Server" you may need to install vcruntime140.dll: +https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170 + Support types ~ * Tier 1: Officially supported and tested with CI. Any contributed patch - MUST NOT break such systems. + MUST NOT break support for such platforms. -* Tier 2: Officially supported, but not necessarily tested with CI. These - systems are maintained to the best of our ability, without being a top +* Tier 2: Officially supported, but not necessarily tested with CI. Support + for these platforms are maintained by best effort, without being a top priority. * Tier 3: Not tested and no guarantees, and not all features may work. @@ -47,7 +50,8 @@ Common Some common notes when adding support for new platforms: -Cmake is the only supported build system. The platform must be buildable with cmake. +CMake is the only supported build system. Nvim must be buildable on the +platform with CMake. All functionality related to the new platform must be implemented in its own file inside `src/nvim/os` unless it's already done in a common file, in which diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 7893822a66..219be92c58 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -152,8 +152,7 @@ add a few items or change the highlighting, follow these steps: 1. Create your user directory from 'runtimepath', see above. 2. Create a directory in there called "after/syntax". For Unix: > - mkdir ~/.config/nvim/after - mkdir ~/.config/nvim/after/syntax + mkdir -p ~/.config/nvim/after/syntax 3. Write a Vim script that contains the commands you want to use. For example, to change the colors for the C syntax: > @@ -466,14 +465,14 @@ ASTRO *astro.vim* *ft-astro-syntax* Configuration The following variables control certain syntax highlighting features. -You can add them to your .vimrc: > +You can add them to your .vimrc. + +To enable TypeScript and TSX for ".astro" files (default "disable"): > let g:astro_typescript = "enable" < -Enables TypeScript and TSX for ".astro" files. Default Value: "disable" > +To enable Stylus for ".astro" files (default "disable"): > let g:astro_stylus = "enable" < -Enables Stylus for ".astro" files. Default Value: "disable" - NOTE: You need to install an external plugin to support stylus in astro files. @@ -489,6 +488,25 @@ For Visual Basic use: > :let g:filetype_asa = "aspvbs" :let g:filetype_asp = "aspvbs" +ASYMPTOTE *asy.vim* *ft-asy-syntax* + +By default, only basic Asymptote keywords are highlighted. To highlight +extended geometry keywords: > + + :let g:asy_syn_plain = 1 + +and for highlighting keywords related to 3D constructions: > + + :let g:asy_syn_three = 1 + +By default, Asymptote-defined colors (e.g: lightblue) are highlighted. To +highlight TeX-defined colors (e.g: BlueViolet) use: > + + :let g:asy_syn_texcolors = 1 + +or for Xorg colors (e.g: AliceBlue): > + + :let g:asy_syn_x11colors = 1 BAAN *baan.vim* *baan-syntax* @@ -752,6 +770,21 @@ will be classified as tcsh, UNLESS the "filetype_csh" variable exists. If the "filetype_csh" variable exists, the filetype will be set to the value of the variable. +CSV *ft-csv-syntax* + +If you change the delimiter of a CSV file, its syntax highlighting will no +longer match the changed file content. You will need to unlet the following +variable: > + + :unlet b:csv_delimiter + +And afterwards save and reload the file: > + + :w + :e + +Now the syntax engine should determine the newly changed CSV delimiter. + CYNLIB *cynlib.vim* *ft-cynlib-syntax* @@ -1402,6 +1435,10 @@ You can also disable this rendering by adding the following line to your vimrc file: > :let html_no_rendering=1 +By default Vim synchronises the syntax to 250 lines before the first displayed +line. This can be configured using: > + :let html_minlines = 500 +< HTML comments are rather special (see an HTML reference document for the details), and the syntax coloring scheme will highlight all errors. However, if you prefer to use the wrong style (starts with <!-- and @@ -1437,7 +1474,7 @@ Note: Syntax folding might slow down syntax highlighting significantly, especially for large files. -HTML/OS (by Aestiva) *htmlos.vim* *ft-htmlos-syntax* +HTML/OS (BY AESTIVA) *htmlos.vim* *ft-htmlos-syntax* The coloring scheme for HTML/OS works as follows: @@ -1521,102 +1558,172 @@ idlsyntax_showerror_soft Use softer colours by default for errors JAVA *java.vim* *ft-java-syntax* -The java.vim syntax highlighting file offers several options: +The java.vim syntax highlighting file offers several options. -In Java 1.0.2 it was never possible to have braces inside parens, so this was -flagged as an error. Since Java 1.1 this is possible (with anonymous -classes), and therefore is no longer marked as an error. If you prefer the -old way, put the following line into your vim startup file: > - :let java_mark_braces_in_parens_as_errors=1 +In Java 1.0.2, it was never possible to have braces inside parens, so this was +flagged as an error. Since Java 1.1, this is possible (with anonymous +classes); and, therefore, is no longer marked as an error. If you prefer the +old way, put the following line into your Vim startup file: > + :let g:java_mark_braces_in_parens_as_errors = 1 -All identifiers in java.lang.* are always visible in all classes. To -highlight them use: > - :let java_highlight_java_lang_ids=1 +All (exported) public types declared in `java.lang` are always automatically +imported and available as simple names. To highlight them, use: > + :let g:java_highlight_java_lang_ids = 1 -You can also highlight identifiers of most standard Java packages if you -download the javaid.vim script at https://www.fleiner.com/vim/download.html. -If you prefer to only highlight identifiers of a certain package, say java.io -use the following: > - :let java_highlight_java_io=1 +You can also highlight types of most standard Java packages if you download +the javaid.vim script at https://www.fleiner.com/vim/download.html. If you +prefer to only highlight types of a certain package, say `java.io`, use the +following: > + :let g:java_highlight_java_io = 1 Check the javaid.vim file for a list of all the packages that are supported. -Function names are not highlighted, as the way to find functions depends on -how you write Java code. The syntax file knows two possible ways to highlight -functions: - -If you write function declarations that are consistently indented by either -a tab, or a space . . . or eight space character(s), you may want to set > - :let java_highlight_functions="indent" - :let java_highlight_functions="indent1" - :let java_highlight_functions="indent2" - :let java_highlight_functions="indent3" - :let java_highlight_functions="indent4" - :let java_highlight_functions="indent5" - :let java_highlight_functions="indent6" - :let java_highlight_functions="indent7" - :let java_highlight_functions="indent8" +Headers of indented function declarations can be highlighted (along with parts +of lambda expressions and method reference expressions), but it depends on how +you write Java code. Two formats are recognized: + +1) If you write function declarations that are consistently indented by either +a tab, or a space . . . or eight space character(s), you may want to set one +of > + :let g:java_highlight_functions = "indent" + :let g:java_highlight_functions = "indent1" + :let g:java_highlight_functions = "indent2" + :let g:java_highlight_functions = "indent3" + :let g:java_highlight_functions = "indent4" + :let g:java_highlight_functions = "indent5" + :let g:java_highlight_functions = "indent6" + :let g:java_highlight_functions = "indent7" + :let g:java_highlight_functions = "indent8" Note that in terms of 'shiftwidth', this is the leftmost step of indentation. -However, if you follow the Java guidelines about how functions and classes are -supposed to be named (with respect to upper- and lowercase) and there is any -amount of indentation, you may want to set > - :let java_highlight_functions="style" -If neither setting does work for you, but you would still want function -declarations to be highlighted, create your own definitions by changing the -definitions in java.vim or by creating your own java.vim that includes the -original one and then adds the code to highlight functions. - -In Java 1.1 the functions System.out.println() and System.err.println() should -only be used for debugging. Therefore it is possible to highlight debugging -statements differently. To do this you must add the following definition in -your startup file: > - :let java_highlight_debug=1 -The result will be that those statements are highlighted as 'Special' -characters. If you prefer to have them highlighted differently you must define -new highlightings for the following groups.: - Debug, DebugSpecial, DebugString, DebugBoolean, DebugType -which are used for the statement itself, special characters used in debug -strings, strings, boolean constants and types (this, super) respectively. I -have opted to choose another background for those statements. + +2) However, if you follow the Java guidelines about how functions and types +are supposed to be named (with respect to upper- and lowercase) and there is +any amount of indentation, you may want to set > + :let g:java_highlight_functions = "style" + +In addition, you can combine any value of "g:java_highlight_functions" with > + :let g:java_highlight_signature = 1 +to have the name of a function with its parameter list parens distinctly +highlighted from its type parameters, return type, and formal parameters; and +to have the parameter list parens of a lambda expression with its arrow +distinctly highlighted from its formal parameters or identifiers. + +If neither setting does work for you, but you would still want headers of +function declarations to be highlighted, modify the current syntax definitions +or compose new ones. + +Higher-order function types can be hard to parse by eye, so uniformly toning +down some of their components may be of value. Provided that such type names +conform to the Java naming guidelines, you may arrange it with > + :let g:java_highlight_generics = 1 + +In Java 1.1, the functions `System.out.println()` and `System.err.println()` +should only be used for debugging. Consider adding the following definition +in your startup file: > + :let g:java_highlight_debug = 1 +to have the bulk of those statements colored as + `*Debug` debugging statements, +and to make some of their own items further grouped and linked: + `*Special` as DebugSpecial, + `*String` as DebugString, + `*Boolean` as DebugBoolean, + `*Type` as DebugType, +which are used for special characters appearing in strings, strings proper, +boolean literals, and special instance references (`super`, `this`, `null`), +respectively. Javadoc is a program that takes special comments out of Java program files and creates HTML pages. The standard configuration will highlight this HTML code -similarly to HTML files (see |html.vim|). You can even add Javascript -and CSS inside this code (see below). There are four differences however: - 1. The title (all characters up to the first '.' which is followed by - some white space or up to the first '@') is colored differently (to change - the color change the group CommentTitle). - 2. The text is colored as 'Comment'. - 3. HTML comments are colored as 'Special' - 4. The special Javadoc tags (@see, @param, ...) are highlighted as specials - and the argument (for @see, @param, @exception) as Function. -To turn this feature off add the following line to your startup file: > - :let java_ignore_javadoc=1 - -If you use the special Javadoc comment highlighting described above you -can also turn on special highlighting for Javascript, visual basic -scripts and embedded CSS (stylesheets). This makes only sense if you -actually have Javadoc comments that include either Javascript or embedded -CSS. The options to use are > - :let java_javascript=1 - :let java_css=1 - :let java_vb=1 - -In order to highlight nested parens with different colors define colors -for javaParen, javaParen1 and javaParen2, for example with > +similarly to HTML files (see |html.vim|). You can even add JavaScript and CSS +inside this code (see below). The HTML rendering and the Markdown rendering +diverge as follows: + 1. The first sentence (all characters up to the first period `.`, which is + followed by a whitespace character or a line terminator, or up to the + first block tag, e.g. `@param`, `@return`) is colored as + *SpecialComment special comments. + 2. The text is colored as + `*Comment` comments. + 3. HTML comments are colored as + `*Special` special symbols. + 4. The standard Javadoc tags (`@code`, `@see`, etc.) are colored as + `*Special` special symbols + and some of their arguments are colored as + `*Function` function names. +To turn this feature off for both HTML and Markdown, add the following line to +your startup file: > + :let g:java_ignore_javadoc = 1 +Alternatively, only suppress HTML comments or Markdown comments: > + :let g:java_ignore_html = 1 + :let g:java_ignore_markdown = 1 +See |ft-java-plugin| for additional support available for Markdown comments. + +If you use the special Javadoc comment highlighting described above, you can +also turn on special highlighting for JavaScript, Visual Basic scripts, and +embedded CSS (stylesheets). This only makes sense if any of these languages +actually appear in Javadoc comments. The variables to use are > + :let g:java_javascript = 1 + :let g:java_css = 1 + :let g:java_vb = 1 +Note that these three variables are maintained in the HTML syntax file. + +Numbers and strings can be recognized in non-Javadoc comments with > + :let g:java_comment_strings = 1 + +When 'foldmethod' is set to "syntax", blocks of code and multi-line comments +will be folded. No text is usually written in the first line of a multi-line +comment, making folded contents of Javadoc comments less informative with the +default 'foldtext' value; you may opt for showing the contents of a second +line for any comments written in this way, and showing the contents of a first +line otherwise, with > + :let g:java_foldtext_show_first_or_second_line = 1 + +Trailing whitespace characters or a run of space characters before a tab +character can be marked as an error with > + :let g:java_space_errors = 1 +but either kind of an error can be suppressed by also defining one of > + :let g:java_no_trail_space_error = 1 + :let g:java_no_tab_space_error = 1 + +In order to highlight nested parens with different colors, define colors for +`javaParen`, `javaParen1`, and `javaParen2`. For example, > :hi link javaParen Comment or > :hi javaParen ctermfg=blue guifg=#0000ff +Certain modifiers are incompatible with each other, e.g. `abstract` and +`final`: > + :syn list javaConceptKind +and can be differently highlighted as a group than other modifiers with > + :hi link javaConceptKind NonText + If you notice highlighting errors while scrolling backwards, which are fixed -when redrawing with CTRL-L, try setting the "java_minlines" internal variable -to a larger number: > - :let java_minlines = 50 +when redrawing with CTRL-L, try setting the "g:java_minlines" variable to +a larger number: > + :let g:java_minlines = 50 This will make the syntax synchronization start 50 lines before the first displayed line. The default value is 10. The disadvantage of using a larger number is that redrawing can become slow. +Significant changes to the Java platform are gradually introduced in the form +of JDK Enhancement Proposals (JEPs) that can be implemented for a release and +offered as its preview features. It may take several JEPs and a few release +cycles for such a feature to become either integrated into the platform or +withdrawn from this effort. To cater for early adopters, there is optional +support in Vim for syntax related preview features that are implemented. You +can request it by specifying a list of preview feature numbers as follows: > + :let g:java_syntax_previews = [455, 476] + +The supported JEP numbers are to be drawn from this table: + `430`: String Templates [JDK 21] + `455`: Primitive types in Patterns, instanceof, and switch + `476`: Module Import Declarations + +Note that as soon as the particular preview feature will have been integrated +into the Java platform, its entry will be removed from the table and related +optionality will be discontinued. + -JSON *json.vim* *ft-json-syntax* +JSON *json.vim* *ft-json-syntax* *g:vim_json_conceal* + *g:vim_json_warnings* The json syntax file provides syntax highlighting with conceal support by default. To disable concealment: > @@ -1759,7 +1866,7 @@ By default mail.vim synchronises syntax to 100 lines before the first displayed line. If you have a slow machine, and generally deal with emails with short headers, you can change this to a smaller value: > - :let mail_minlines = 30 + :let mail_minlines = 30 MAKE *make.vim* *ft-make-syntax* @@ -1770,6 +1877,16 @@ feature off by using: > :let make_no_commands = 1 +Comments are also highlighted by default. You can turn this off by using: > + + :let make_no_comments = 1 + +Microsoft Makefile handles variable expansion and comments differently +(backslashes are not used for escape). If you see any wrong highlights +because of this, you can try this: > + + :let make_microsoft = 1 + MAPLE *maple.vim* *ft-maple-syntax* @@ -1796,7 +1913,8 @@ $VIMRUNTIME/syntax/syntax.vim). mv_finance mv_logic mv_powseries -MARKDOWN *ft-markdown-syntax* +MARKDOWN *ft-markdown-syntax* *g:markdown_minlines* + *g:markdown_fenced_languages* *g:markdown_syntax_conceal* If you have long regions there might be wrong highlighting. At the cost of slowing down displaying, you can have the engine look further back to sync on @@ -1821,6 +1939,17 @@ have the following in your vimrc: > let filetype_m = "mma" +MEDIAWIKI *ft-mediawiki-syntax* + +By default, syntax highlighting includes basic HTML tags like style and +headers |html.vim|. For strict Mediawiki syntax highlighting: > + + let g:html_no_rendering = 1 + +If HTML highlighting is desired, terminal-based text formatting such as bold +and italic is possible by: > + + let g:html_style_rendering = 1 MODULA2 *modula2.vim* *ft-modula2-syntax* @@ -2034,9 +2163,9 @@ PANDOC *ft-pandoc-syntax* By default, markdown files will be detected as filetype "markdown". Alternatively, you may want them to be detected as filetype "pandoc" instead. -To do so, set the following: > +To do so, set the *g:filetype_md* var: > - :let g:markdown_md = 'pandoc' + :let g:filetype_md = 'pandoc' The pandoc syntax plugin uses |conceal| for pretty highlighting. Default is 1 > @@ -2575,6 +2704,13 @@ To highlight R code in knitr chunk headers, add to your |vimrc|: > let rrst_syn_hl_chunk = 1 +RASI *rasi.vim* *ft-rasi-syntax* + +Rasi stands for Rofi Advanced Style Information. It is used by the program +rofi to style the rendering of the search window. The language is heavily +inspired by CSS stylesheet. Files with the following extensions are recognized +as rasi files: .rasi. + READLINE *readline.vim* *ft-readline-syntax* The readline library is primarily used by the BASH shell, which adds quite a @@ -3289,6 +3425,28 @@ set "tf_minlines" to the value you desire. Example: > :let tf_minlines = your choice < +TYPESCRIPT *typescript.vim* *ft-typescript-syntax* + *typescriptreact.vim* *ft-typescriptreact-syntax* + +There is one option to control the TypeScript syntax highlighting. + + *g:typescript_host_keyword* +When this variable is set to 1, host-specific APIs such as `addEventListener` +are highlighted. To disable set it to zero in your .vimrc: > + + let g:typescript_host_keyword = 0 +< +The default value is 1. + +TYPST *ft-typst-syntax* + + *g:typst_embedded_languages* +Typst files can embed syntax highlighting for other languages by setting the +|g:typst_embedded_languages| variable. This variable is a list of language +names whose syntax definitions will be included in Typst files. Example: > + + let g:typst_embedded_languages = ['python', 'r'] + VIM *vim.vim* *ft-vim-syntax* *g:vimsyn_minlines* *g:vimsyn_maxlines* There is a trade-off between more accurate syntax highlighting versus screen @@ -3307,23 +3465,31 @@ The g:vimsyn_embed option allows users to select what, if any, types of embedded script highlighting they wish to have. > g:vimsyn_embed == 0 : disable (don't embed any scripts) - g:vimsyn_embed == 'lpPr' : support embedded lua, perl, python and ruby + g:vimsyn_embed == 'lpPr' : support embedded Lua, Perl, Python and Ruby < This option is disabled by default. *g:vimsyn_folding* - -Some folding is now supported with syntax/vim.vim: > +Some folding is now supported with when 'foldmethod' is set to "syntax": > g:vimsyn_folding == 0 or doesn't exist: no syntax-based folding g:vimsyn_folding =~ 'a' : augroups g:vimsyn_folding =~ 'f' : fold functions g:vimsyn_folding =~ 'h' : fold heredocs - g:vimsyn_folding =~ 'l' : fold lua script - g:vimsyn_folding =~ 'p' : fold perl script - g:vimsyn_folding =~ 'P' : fold python script - g:vimsyn_folding =~ 'r' : fold ruby script + g:vimsyn_folding =~ 'l' : fold Lua script + g:vimsyn_folding =~ 'p' : fold Perl script + g:vimsyn_folding =~ 'P' : fold Python script + g:vimsyn_folding =~ 'r' : fold Ruby script < - *g:vimsyn_noerror* + +By default, g:vimsyn_folding is unset. Concatenate the indicated characters +to support folding of multiple syntax constructs (e.g., +g:vimsyn_folding = "fh" will enable folding of both functions and heredocs). + + *g:vimsyn_comment_strings* +By default, strings are highlighted inside comments. This may be disabled by +setting g:vimsyn_comment_strings to false. + + *g:vimsyn_noerror* Not all error highlighting that syntax/vim.vim does may be correct; Vim script is a difficult language to highlight correctly. A way to suppress error highlighting is to put the following line in your |vimrc|: > @@ -4527,7 +4693,7 @@ matches, nextgroup, etc. But there are a few differences: line (or group of continued lines). - When a match with a sync pattern is found, the rest of the line (or group of continued lines) is searched for another match. The last match is used. - This is used when a line can contain both the start end the end of a region + This is used when a line can contain both the start and the end of a region (e.g., in a C-comment like `/* this */`, the last "*/" is used). There are two ways how a match with a sync pattern can be used: @@ -4926,11 +5092,13 @@ guisp={color-name} *guisp* All values are hexadecimal, range from "00" to "ff". Examples: > :highlight Comment guifg=#11f0c3 guibg=#ff00ff < -blend={integer} *highlight-blend* +blend={integer} *highlight-blend* *opacity* Override the blend level for a highlight group within the popupmenu or floating windows. Only takes effect if 'pumblend' or 'winblend' is set for the menu or window. See the help at the respective option. + See also the "blend" flag of |nvim_buf_set_extmark()|. + *highlight-groups* *highlight-default* These are the builtin highlighting groups. Note that the highlighting depends on the value of 'background'. You can see the current settings with the @@ -4941,8 +5109,9 @@ ColorColumn Used for the columns set with 'colorcolumn'. Conceal Placeholder characters substituted for concealed text (see 'conceallevel'). *hl-CurSearch* -CurSearch Used for highlighting a search pattern under the cursor - (see 'hlsearch'). +CurSearch Current match for the last search pattern (see 'hlsearch'). + Note: This is correct after a search, but may get outdated if + changes are made or the screen is redrawn. *hl-Cursor* *hl-lCursor* Cursor Character under the cursor. lCursor Character under the cursor when |language-mapping| @@ -4986,7 +5155,6 @@ IncSearch 'incsearch' highlighting; also used for the text replaced with ":s///c". *hl-Substitute* Substitute |:substitute| replacement text highlighting. - *hl-LineNr* LineNr Line number for ":number" and ":#" commands, and when 'number' or 'relativenumber' option is set. @@ -5006,7 +5174,6 @@ CursorLineSign Like SignColumn when 'cursorline' is set for the cursor line. *hl-MatchParen* MatchParen Character under the cursor or just before it, if it is a paired bracket, and its match. |pi_paren.txt| - *hl-ModeMsg* ModeMsg 'showmode' message (e.g., "-- INSERT --"). *hl-MsgArea* @@ -5048,11 +5215,15 @@ PmenuExtraSel Popup menu: Selected item "extra text". PmenuSbar Popup menu: Scrollbar. *hl-PmenuThumb* PmenuThumb Popup menu: Thumb of the scrollbar. + *hl-PmenuMatch* +PmenuMatch Popup menu: Matched text in normal item. + *hl-PmenuMatchSel* +PmenuMatchSel Popup menu: Matched text in selected item. *hl-Question* Question |hit-enter| prompt and yes/no questions. *hl-QuickFixLine* QuickFixLine Current |quickfix| item in the quickfix window. Combined with - |hl-CursorLine| when the cursor is there. + |hl-CursorLine| when the cursor is there. *hl-Search* Search Last search pattern highlighting (see 'hlsearch'). Also used for similar items that need to stand out. @@ -5079,6 +5250,11 @@ SpellRare Word that is recognized by the spellchecker as one that is StatusLine Status line of current window. *hl-StatusLineNC* StatusLineNC Status lines of not-current windows. + *hl-StatusLineTerm* +StatusLineTerm Status line of |terminal| window. + *hl-StatusLineTermNC* +StatusLineTermNC + Status line of non-current |terminal| windows. *hl-TabLine* TabLine Tab pages line, not active tab page label. *hl-TabLineFill* diff --git a/runtime/doc/tabpage.txt b/runtime/doc/tabpage.txt index 2f50e31ee5..7bfa36e8ab 100644 --- a/runtime/doc/tabpage.txt +++ b/runtime/doc/tabpage.txt @@ -135,7 +135,8 @@ something else. :tabclose $ " close the last tab page :tabclose # " close the last accessed tab page -When a tab is closed the next tab page will become the current one. +When a tab is closed the next tab page will become the current one. This +behaviour can be customized using the 'tabclose' option. *:tabo* *:tabonly* :tabo[nly][!] Close all other tab pages. diff --git a/runtime/doc/tagsrch.txt b/runtime/doc/tagsrch.txt index ef1654d365..d5e165a870 100644 --- a/runtime/doc/tagsrch.txt +++ b/runtime/doc/tagsrch.txt @@ -274,25 +274,25 @@ g CTRL-] Like CTRL-], but use ":tjump" instead of ":tag". {Visual}g CTRL-] Same as "g CTRL-]", but use the highlighted text as the identifier. - *:tn* *:tnext* + *:tn* *:tnext* *]t* :[count]tn[ext][!] Jump to [count] next matching tag (default 1). See |tag-!| for [!]. - *:tp* *:tprevious* + *:tp* *:tprevious* *[t* :[count]tp[revious][!] Jump to [count] previous matching tag (default 1). See |tag-!| for [!]. *:tN* *:tNext* :[count]tN[ext][!] Same as ":tprevious". - *:tr* *:trewind* + *:tr* *:trewind* *[T* :[count]tr[ewind][!] Jump to first matching tag. If [count] is given, jump to [count]th matching tag. See |tag-!| for [!]. *:tf* *:tfirst* :[count]tf[irst][!] Same as ":trewind". - *:tl* *:tlast* + *:tl* *:tlast* *]T* :tl[ast][!] Jump to last matching tag. See |tag-!| for [!]. *:lt* *:ltag* @@ -335,10 +335,10 @@ the same as above, with a "p" prepended. :ptj[ump][!] [name] Does ":tjump[!] [name]" and shows the new tag in a "Preview" window. See |:ptag| for more info. - *:ptn* *:ptnext* + *:ptn* *:ptnext* *]CTRL-T* :[count]ptn[ext][!] ":tnext" in the preview window. See |:ptag|. - *:ptp* *:ptprevious* + *:ptp* *:ptprevious* *[CTRL-T* :[count]ptp[revious][!] ":tprevious" in the preview window. See |:ptag|. *:ptN* *:ptNext* @@ -565,12 +565,12 @@ ctags). {term} ;" The two characters semicolon and double quote. This is interpreted by Vi as the start of a comment, which makes the following be ignored. This is for backwards compatibility - with Vi, it ignores the following fields. Example: + with Vi, it ignores the following fields. Example: > APP file /^static int APP;$/;" v - When {tagaddress} is not a line number or search pattern, then +< When {tagaddress} is not a line number or search pattern, then {term} must be `|;"`. Here the bar ends the command (excluding the bar) and `;"` is used to have Vi ignore the rest of the - line. Example: + line. Example: > APP file.c call cursor(3, 4)|;" v {field} .. A list of optional fields. Each field has the form: @@ -588,7 +588,9 @@ ctags). There is one field that doesn't have a ':'. This is the kind of the tag. It is handled like it was preceded with "kind:". - See the documentation of ctags for the kinds it produces. + In the above example, this was "kind:v" (typically variable). + See the documentation of ctags for the kinds it produces, with + ctags you can use `ctags --list-kinds` . The only other field currently recognized by Vim is "file:" (with an empty value). It is used for a static tag. @@ -633,14 +635,14 @@ If the command is a normal search command (it starts and ends with "/" or The direction of the search is forward for "/", backward for "?". Note that 'wrapscan' does not matter, the whole file is always searched. - If the search fails, another try is done ignoring case. If that fails too, - a search is done for: + a search is done for: > "^tagname[ \t]*(" - (the tag with '^' prepended and "[ \t]*(" appended). When using function +< (the tag with '^' prepended and "[ \t]*(" appended). When using function names, this will find the function name when it is in column 0. This will help when the arguments to the function have changed since the tags file was - made. If this search also fails another search is done with: + made. If this search also fails another search is done with: > "^[#a-zA-Z_].*\<tagname[ \t]*(" - This means: A line starting with '#' or an identifier and containing the tag +< This means: A line starting with '#' or an identifier and containing the tag followed by white space and a '('. This will find macro names and function names with a type prepended. @@ -781,15 +783,15 @@ CTRL-W i Open a new window, with the cursor on the first line count'th matching line is displayed. *[d-default* - Mapped to |vim.diagnostic.goto_prev()| by default. - |default-mappings| + Jumps to the previous diagnostic in the current buffer + by default. |vim.diagnostic.jump()| |default-mappings| *]d* ]d like "[d", but start at the current cursor position. *]d-default* - Mapped to |vim.diagnostic.goto_next()| by default. - |default-mappings| + Jumps to the next diagnostic in the current buffer by + default. |vim.diagnostic.jump()| |default-mappings| *:ds* *:dsearch* :[range]ds[earch][!] [count] [/]string[/] @@ -803,9 +805,17 @@ CTRL-W i Open a new window, with the cursor on the first line displayed for the found lines. The search starts from the beginning of the file. + *[D-default* + Jumps to the first diagnostic in the current buffer by + default. |vim.diagnostic.jump()| |default-mappings| + *]D* ]D like "[D", but start at the current cursor position. + *]D-default* + Jumps to the last diagnostic in the current buffer by + default. |vim.diagnostic.jump()| |default-mappings| + *:dli* *:dlist* :[range]dli[st][!] [/]string[/] Like `[D` and `]D`, but search in [range] lines diff --git a/runtime/doc/nvim_terminal_emulator.txt b/runtime/doc/terminal.txt index a6ebc7e958..9c47e6de7d 100644 --- a/runtime/doc/nvim_terminal_emulator.txt +++ b/runtime/doc/terminal.txt @@ -1,4 +1,4 @@ -*terminal_emulator.txt* Nvim +*terminal.txt* Nvim NVIM REFERENCE MANUAL by Thiago de Arruda @@ -164,7 +164,22 @@ directory indicated in the request. >lua To try it out, select the above code and source it with `:'<,'>lua`, then run this command in a :terminal buffer: > - printf "\033]7;file://./foo/bar\033\\" + printf "\033]7;file://./foo/bar\033\\" + +OSC 52: write to system clipboard *terminal-osc52* + +Applications in the :terminal buffer can write to the system clipboard by +emitting an OSC 52 sequence. Example: > + + printf '\033]52;;%s\033\\' "$(echo -n 'Hello world' | base64)" + +Nvim uses the configured |clipboard| provider to write to the system +clipboard. Reading from the system clipboard with OSC 52 is not supported, as +this would allow any arbitrary program in the :terminal to read the user's +clipboard. + +OSC 52 sequences sent from the :terminal buffer do not emit a |TermRequest| +event. The event is handled directly by Nvim and is not forwarded to plugins. ============================================================================== Status Variables *terminal-status* @@ -186,7 +201,7 @@ Example: >vim Use |jobwait()| to check if the terminal job has finished: >vim let running = jobwait([&channel], 0)[0] == -1 - +< ============================================================================== :Termdebug plugin *terminal-debug* @@ -198,6 +213,8 @@ Starting ~ *termdebug-starting* Load the plugin with this command: >vim packadd termdebug +When loading the plugin from the |vimrc| file, add the "!" attribute: >vim + packadd! termdebug < *:Termdebug* To start debugging use `:Termdebug` or `:TermdebugCommand` followed by the command name, for example: >vim @@ -447,6 +464,9 @@ If there is no g:termdebug_config you can use: >vim let g:termdebug_use_prompt = 1 < Mappings ~ +The termdebug plugin enables a few default mappings. All those mappings +are reset to their original values once the termdebug session concludes. + *termdebug_map_K* *termdebug-mappings* The K key is normally mapped to |:Evaluate| unless a buffer local (|:map-local|) mapping to K already exists. If you do not want this use: >vim diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index 0b84bb60d4..35192cc43d 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -49,151 +49,13 @@ treesitter parser for buffers with filetype `svg` or `xslt`, use: >lua vim.treesitter.language.register('xml', { 'svg', 'xslt' }) < + *treesitter-parsers-wasm* -============================================================================== -TREESITTER TREES *treesitter-tree* - *TSTree* - -A "treesitter tree" represents the parsed contents of a buffer, which can be -used to perform further analysis. It is a |userdata| reference to an object -held by the treesitter library. - -An instance `TSTree` of a treesitter tree supports the following methods. - -TSTree:root() *TSTree:root()* - Return the root node of this tree. - -TSTree:copy() *TSTree:copy()* - Returns a copy of the `TSTree`. - -============================================================================== -TREESITTER NODES *treesitter-node* - *TSNode* - -A "treesitter node" represents one specific element of the parsed contents of -a buffer, which can be captured by a |Query| for, e.g., highlighting. It is -a |userdata| reference to an object held by the treesitter library. - -An instance `TSNode` of a treesitter node supports the following methods. - -TSNode:parent() *TSNode:parent()* - Get the node's immediate parent. - Prefer |TSNode:child_containing_descendant()| - for iterating over the node's ancestors. - -TSNode:next_sibling() *TSNode:next_sibling()* - Get the node's next sibling. - -TSNode:prev_sibling() *TSNode:prev_sibling()* - Get the node's previous sibling. - -TSNode:next_named_sibling() *TSNode:next_named_sibling()* - Get the node's next named sibling. - -TSNode:prev_named_sibling() *TSNode:prev_named_sibling()* - Get the node's previous named sibling. - -TSNode:iter_children() *TSNode:iter_children()* - Iterates over all the direct children of {TSNode}, regardless of whether - they are named or not. - Returns the child node plus the eventual field name corresponding to this - child node. - -TSNode:field({name}) *TSNode:field()* - Returns a table of the nodes corresponding to the {name} field. - -TSNode:child_count() *TSNode:child_count()* - Get the node's number of children. - -TSNode:child({index}) *TSNode:child()* - Get the node's child at the given {index}, where zero represents the first - child. - -TSNode:named_child_count() *TSNode:named_child_count()* - Get the node's number of named children. - -TSNode:named_child({index}) *TSNode:named_child()* - Get the node's named child at the given {index}, where zero represents the - first named child. - -TSNode:child_containing_descendant({descendant}) *TSNode:child_containing_descendant()* - Get the node's child that contains {descendant}. - -TSNode:start() *TSNode:start()* - Get the node's start position. Return three values: the row, column and - total byte count (all zero-based). - -TSNode:end_() *TSNode:end_()* - Get the node's end position. Return three values: the row, column and - total byte count (all zero-based). - -TSNode:range({include_bytes}) *TSNode:range()* - Get the range of the node. - - Return four or six values: - - start row - - start column - - start byte (if {include_bytes} is `true`) - - end row - - end column - - end byte (if {include_bytes} is `true`) - -TSNode:type() *TSNode:type()* - Get the node's type as a string. - -TSNode:symbol() *TSNode:symbol()* - Get the node's type as a numerical id. - -TSNode:named() *TSNode:named()* - Check if the node is named. Named nodes correspond to named rules in the - grammar, whereas anonymous nodes correspond to string literals in the - grammar. - -TSNode:missing() *TSNode:missing()* - Check if the node is missing. Missing nodes are inserted by the parser in - order to recover from certain kinds of syntax errors. - -TSNode:extra() *TSNode:extra()* - Check if the node is extra. Extra nodes represent things like comments, - which are not required by the grammar but can appear anywhere. - -TSNode:has_changes() *TSNode:has_changes()* - Check if a syntax node has been edited. - -TSNode:has_error() *TSNode:has_error()* - Check if the node is a syntax error or contains any syntax errors. - -TSNode:sexpr() *TSNode:sexpr()* - Get an S-expression representing the node as a string. - -TSNode:id() *TSNode:id()* - Get a unique identifier for the node inside its own tree. - - No guarantees are made about this identifier's internal representation, - except for being a primitive Lua type with value equality (so not a - table). Presently it is a (non-printable) string. - - Note: The `id` is not guaranteed to be unique for nodes from different - trees. - -TSNode:tree() *TSNode:tree()* - Get the |TSTree| of the node. - *TSNode:descendant_for_range()* -TSNode:descendant_for_range({start_row}, {start_col}, {end_row}, {end_col}) - Get the smallest node within this node that spans the given range of (row, - column) positions - - *TSNode:named_descendant_for_range()* -TSNode:named_descendant_for_range({start_row}, {start_col}, {end_row}, {end_col}) - Get the smallest named node within this node that spans the given range of - (row, column) positions - *TSNode:equal()* -TSNode:equal({node}) - Check if {node} refers to the same node within the same tree. +If Nvim is built with `ENABLE_WASMTIME`, then wasm parsers can also be +loaded: >lua - *TSNode:byte_length()* -TSNode:byte_length() - Return the number of bytes spanned by this node. + vim.treesitter.language.add('python', { path = "/path/to/python.wasm" }) +< ============================================================================== TREESITTER QUERIES *treesitter-query* @@ -335,7 +197,7 @@ TREESITTER QUERY DIRECTIVES *treesitter-directives* Treesitter directives store metadata for a node or match and perform side effects. For example, the `set!` directive sets metadata on the match or node: >query - ((identifier) @foo (#set! "type" "parameter")) + ((identifier) @foo (#set! type "parameter")) < The following directives are built in: @@ -350,13 +212,14 @@ The following directives are built in: {value} Examples: >query - ((identifier) @foo (#set! @foo "kind" "parameter")) - ((node1) @left (node2) @right (#set! "type" "pair")) - ((codeblock) @markup.raw.block (#set! "priority" 90)) + ((identifier) @foo (#set! @foo kind "parameter")) + ((node1) @left (node2) @right (#set! type "pair")) + ((codeblock) @markup.raw.block (#set! priority 90)) < `offset!` *treesitter-directive-offset!* Takes the range of the captured node and applies an offset. This will - set a new `Range4` object for the captured node with `capture_id` as + set a new range in the form of a list like { {start_row}, {start_col}, + {end_row}, {end_col} } for the captured node with `capture_id` as `metadata[capture_id].range`. Useful for |treesitter-language-injections|. Parameters: ~ @@ -540,9 +403,9 @@ the exact definition): @keyword.coroutine keywords related to coroutines (e.g. `go` in Go, `async/await` in Python) @keyword.function keywords that define a function (e.g. `func` in Go, `def` in Python) @keyword.operator operators that are English words (e.g. `and`, `or`) -@keyword.import keywords for including modules (e.g. `import`, `from` in Python) -@keyword.type keywords defining composite types (e.g. `struct`, `enum`) -@keyword.modifier keywords defining type modifiers (e.g. `const`, `static`, `public`) +@keyword.import keywords for including or exporting modules (e.g. `import`, `from` in Python) +@keyword.type keywords describing namespaces and composite types (e.g. `struct`, `enum`) +@keyword.modifier keywords modifying other constructs (e.g. `const`, `static`, `public`) @keyword.repeat keywords related to loops (e.g. `for`, `while`) @keyword.return keywords like `return` and `yield` @keyword.debug keywords related to debugging @@ -598,7 +461,7 @@ the exact definition): @diff.delta changed text (for diff files) @tag XML-style tag names (e.g. in XML, HTML, etc.) -@tag.builtin XML-style tag names (e.g. HTML5 tags) +@tag.builtin builtin tag names (e.g. HTML5 tags) @tag.attribute XML-style tag attributes @tag.delimiter XML-style tag delimiters @@ -636,7 +499,7 @@ higher than treesitter. It is also possible to change the priority of an individual query pattern manually by setting its `"priority"` metadata attribute: >query - ((super_important_node) @superimportant (#set! "priority" 105)) + ((super_important_node) @superimportant (#set! priority 105)) < ============================================================================== @@ -711,6 +574,278 @@ The earliest parser ABI version that is supported by the bundled treesitter library. ============================================================================== +TREESITTER TREES *treesitter-tree* *TSTree* + +A "treesitter tree" represents the parsed contents of a buffer, which can be +used to perform further analysis. It is a |userdata| reference to an object +held by the treesitter library. + +An instance `TSTree` of a treesitter tree supports the following methods. + + +TSTree:copy() *TSTree:copy()* + Returns a copy of the `TSTree`. + + Return: ~ + (`TSTree`) + +TSTree:root() *TSTree:root()* + Return the root node of this tree. + + Return: ~ + (`TSNode`) + + +============================================================================== +TREESITTER NODES *treesitter-node* *TSNode* + +A "treesitter node" represents one specific element of the parsed contents of +a buffer, which can be captured by a |Query| for, e.g., highlighting. It is a +|userdata| reference to an object held by the treesitter library. + +An instance `TSNode` of a treesitter node supports the following methods. + + +TSNode:byte_length() *TSNode:byte_length()* + Return the number of bytes spanned by this node. + + Return: ~ + (`integer`) + +TSNode:child({index}) *TSNode:child()* + Get the node's child at the given {index}, where zero represents the first + child. + + Parameters: ~ + • {index} (`integer`) + + Return: ~ + (`TSNode?`) + + *TSNode:child_containing_descendant()* +TSNode:child_containing_descendant({descendant}) + Get the node's child that contains {descendant}. + + Parameters: ~ + • {descendant} (`TSNode`) + + Return: ~ + (`TSNode?`) + +TSNode:child_count() *TSNode:child_count()* + Get the node's number of children. + + Return: ~ + (`integer`) + + *TSNode:descendant_for_range()* +TSNode:descendant_for_range({start_row}, {start_col}, {end_row}, {end_col}) + Get the smallest node within this node that spans the given range of (row, + column) positions + + Parameters: ~ + • {start_row} (`integer`) + • {start_col} (`integer`) + • {end_row} (`integer`) + • {end_col} (`integer`) + + Return: ~ + (`TSNode?`) + +TSNode:end_() *TSNode:end_()* + Get the node's end position. Return three values: the row, column and + total byte count (all zero-based). + + Return (multiple): ~ + (`integer`) + (`integer`) + (`integer`) + +TSNode:equal({node}) *TSNode:equal()* + Check if {node} refers to the same node within the same tree. + + Parameters: ~ + • {node} (`TSNode`) + + Return: ~ + (`boolean`) + +TSNode:extra() *TSNode:extra()* + Check if the node is extra. Extra nodes represent things like comments, + which are not required by the grammar but can appear anywhere. + + Return: ~ + (`boolean`) + +TSNode:field({name}) *TSNode:field()* + Returns a table of the nodes corresponding to the {name} field. + + Parameters: ~ + • {name} (`string`) + + Return: ~ + (`TSNode[]`) + +TSNode:has_changes() *TSNode:has_changes()* + Check if a syntax node has been edited. + + Return: ~ + (`boolean`) + +TSNode:has_error() *TSNode:has_error()* + Check if the node is a syntax error or contains any syntax errors. + + Return: ~ + (`boolean`) + +TSNode:id() *TSNode:id()* + Get a unique identifier for the node inside its own tree. + + No guarantees are made about this identifier's internal representation, + except for being a primitive Lua type with value equality (so not a + table). Presently it is a (non-printable) string. + + Note: The `id` is not guaranteed to be unique for nodes from different + trees. + + Return: ~ + (`string`) + +TSNode:iter_children() *TSNode:iter_children()* + Iterates over all the direct children of {TSNode}, regardless of whether + they are named or not. Returns the child node plus the eventual field name + corresponding to this child node. + + Return: ~ + (`fun(): TSNode, string`) + +TSNode:missing() *TSNode:missing()* + Check if the node is missing. Missing nodes are inserted by the parser in + order to recover from certain kinds of syntax errors. + + Return: ~ + (`boolean`) + +TSNode:named() *TSNode:named()* + Check if the node is named. Named nodes correspond to named rules in the + grammar, whereas anonymous nodes correspond to string literals in the + grammar. + + Return: ~ + (`boolean`) + +TSNode:named_child({index}) *TSNode:named_child()* + Get the node's named child at the given {index}, where zero represents the + first named child. + + Parameters: ~ + • {index} (`integer`) + + Return: ~ + (`TSNode?`) + +TSNode:named_child_count() *TSNode:named_child_count()* + Get the node's number of named children. + + Return: ~ + (`integer`) + + *TSNode:named_descendant_for_range()* +TSNode:named_descendant_for_range({start_row}, {start_col}, {end_row}, + {end_col}) + Get the smallest named node within this node that spans the given range of + (row, column) positions + + Parameters: ~ + • {start_row} (`integer`) + • {start_col} (`integer`) + • {end_row} (`integer`) + • {end_col} (`integer`) + + Return: ~ + (`TSNode?`) + +TSNode:next_named_sibling() *TSNode:next_named_sibling()* + Get the node's next named sibling. + + Return: ~ + (`TSNode?`) + +TSNode:next_sibling() *TSNode:next_sibling()* + Get the node's next sibling. + + Return: ~ + (`TSNode?`) + +TSNode:parent() *TSNode:parent()* + Get the node's immediate parent. Prefer + |TSNode:child_containing_descendant()| for iterating over the node's + ancestors. + + Return: ~ + (`TSNode?`) + +TSNode:prev_named_sibling() *TSNode:prev_named_sibling()* + Get the node's previous named sibling. + + Return: ~ + (`TSNode?`) + +TSNode:prev_sibling() *TSNode:prev_sibling()* + Get the node's previous sibling. + + Return: ~ + (`TSNode?`) + +TSNode:range({include_bytes}) *TSNode:range()* + Get the range of the node. + + Return four or six values: + • start row + • start column + • start byte (if {include_bytes} is `true`) + • end row + • end column + • end byte (if {include_bytes} is `true`) + + Parameters: ~ + • {include_bytes} (`boolean?`) + +TSNode:sexpr() *TSNode:sexpr()* + Get an S-expression representing the node as a string. + + Return: ~ + (`string`) + +TSNode:start() *TSNode:start()* + Get the node's start position. Return three values: the row, column and + total byte count (all zero-based). + + Return (multiple): ~ + (`integer`) + (`integer`) + (`integer`) + +TSNode:symbol() *TSNode:symbol()* + Get the node's type as a numerical id. + + Return: ~ + (`integer`) + +TSNode:tree() *TSNode:tree()* + Get the |TSTree| of the node. + + Return: ~ + (`TSTree`) + +TSNode:type() *TSNode:type()* + Get the node's type as a string. + + Return: ~ + (`string`) + + +============================================================================== Lua module: vim.treesitter *lua-treesitter-core* foldexpr({lnum}) *vim.treesitter.foldexpr()* @@ -719,6 +854,9 @@ foldexpr({lnum}) *vim.treesitter.foldexpr()* vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()' < + Attributes: ~ + Since: 0.9.0 + Parameters: ~ • {lnum} (`integer?`) Line number to calculate fold level for @@ -749,7 +887,7 @@ get_captures_at_pos({bufnr}, {row}, {col}) • {col} (`integer`) Position column Return: ~ - (`{capture: string, lang: string, metadata: table}[]`) + (`{capture: string, lang: string, metadata: vim.treesitter.query.TSMetadata}[]`) get_node({opts}) *vim.treesitter.get_node()* Returns the smallest named node at the given position @@ -764,13 +902,15 @@ get_node({opts}) *vim.treesitter.get_node()* • {opts} (`table?`) Optional keyword arguments: • {bufnr} (`integer?`) Buffer number (nil or 0 for current buffer) - • {pos} (`{ [1]: integer, [2]: integer }?`) 0-indexed (row, - col) tuple. Defaults to cursor position in the current - window. Required if {bufnr} is not the current buffer + • {pos} (`[integer, integer]?`) 0-indexed (row, col) tuple. + Defaults to cursor position in the current window. Required + if {bufnr} is not the current buffer • {lang} (`string?`) Parser language. (default: from buffer filetype) • {ignore_injections} (`boolean?`) Ignore injected languages (default true) + • {include_anonymous} (`boolean?`) Include anonymous nodes + (default false) Return: ~ (`TSNode?`) Node at the given position @@ -808,6 +948,11 @@ get_parser({bufnr}, {lang}, {opts}) *vim.treesitter.get_parser()* If needed, this will create the parser. + If no parser can be created, an error is thrown. Set `opts.error = false` + to suppress this and return nil (and an error message) instead. WARNING: + This behavior will become default in Nvim 0.12 and the option will be + removed. + Parameters: ~ • {bufnr} (`integer?`) Buffer the parser should be tied to (default: current buffer) @@ -815,8 +960,9 @@ get_parser({bufnr}, {lang}, {opts}) *vim.treesitter.get_parser()* filetype) • {opts} (`table?`) Options to pass to the created language tree - Return: ~ - (`vim.treesitter.LanguageTree`) object to use for parsing + Return (multiple): ~ + (`vim.treesitter.LanguageTree?`) object to use for parsing + (`string?`) error message, if applicable get_range({node}, {source}, {metadata}) *vim.treesitter.get_range()* Get the range of a |TSNode|. Can also supply {source} and {metadata} to @@ -829,7 +975,13 @@ get_range({node}, {source}, {metadata}) *vim.treesitter.get_range()* • {metadata} (`vim.treesitter.query.TSMetadata?`) Return: ~ - (`Range6`) + (`table`) A table with the following fields: + • {[1]} (`integer`) start row + • {[2]} (`integer`) start column + • {[3]} (`integer`) start bytes + • {[4]} (`integer`) end row + • {[5]} (`integer`) end column + • {[6]} (`integer`) end bytes *vim.treesitter.get_string_parser()* get_string_parser({str}, {lang}, {opts}) @@ -854,6 +1006,9 @@ inspect_tree({opts}) *vim.treesitter.inspect_tree()* Can also be shown with `:InspectTree`. *:InspectTree* + Attributes: ~ + Since: 0.9.0 + Parameters: ~ • {opts} (`table?`) Optional options table with the following possible keys: @@ -942,19 +1097,29 @@ add({lang}, {opts}) *vim.treesitter.language.add()* Load parser with name {lang} Parsers are searched in the `parser` runtime directory, or the provided - {path} + {path}. Can be used to check for available parsers before enabling + treesitter features, e.g., >lua + if vim.treesitter.language.add('markdown') then + vim.treesitter.start(bufnr, 'markdown') + end +< Parameters: ~ • {lang} (`string`) Name of the parser (alphanumerical and `_` only) • {opts} (`table?`) Options: - • {filetype}? (`string|string[]`, default: {lang}) Default - filetype the parser should be associated with. • {path}? (`string`) Optional path the parser is located at • {symbol_name}? (`string`) Internal symbol name for the language to load + Return (multiple): ~ + (`boolean?`) True if parser is loaded + (`string?`) Error if parser cannot be loaded + get_filetypes({lang}) *vim.treesitter.language.get_filetypes()* - Get the filetypes associated with the parser named {lang}. + Returns the filetypes for which a parser named {lang} is used. + + The list includes {lang} itself plus all filetypes registered via + |vim.treesitter.language.register()|. Parameters: ~ • {lang} (`string`) Name of parser @@ -963,6 +1128,11 @@ get_filetypes({lang}) *vim.treesitter.language.get_filetypes()* (`string[]`) filetypes get_lang({filetype}) *vim.treesitter.language.get_lang()* + Returns the language name to be used when loading a parser for {filetype}. + + If no language has been explicitly registered via + |vim.treesitter.language.register()|, default to {filetype}. For composite + filetypes like `html.glimmer`, only the main filetype is returned. Parameters: ~ • {filetype} (`string`) @@ -1007,7 +1177,7 @@ add_directive({name}, {handler}, {opts}) Parameters: ~ • {name} (`string`) Name of the directive, without leading # - • {handler} (`fun(match: table<integer,TSNode[]>, pattern: integer, source: integer|string, predicate: any[], metadata: table)`) + • {handler} (`fun(match: table<integer,TSNode[]>, pattern: integer, source: integer|string, predicate: any[], metadata: vim.treesitter.query.TSMetadata)`) • match: A table mapping capture IDs to a list of captured nodes • pattern: the index of the matching pattern in the query @@ -1020,9 +1190,8 @@ add_directive({name}, {handler}, {opts}) the same name • {all}? (`boolean`) Use the correct implementation of the match table where capture IDs map to a list of nodes - instead of a single node. Defaults to false (for backward - compatibility). This option will eventually become the - default and removed. + instead of a single node. Defaults to true. This option + will be removed in a future release. *vim.treesitter.query.add_predicate()* add_predicate({name}, {handler}, {opts}) @@ -1030,17 +1199,16 @@ add_predicate({name}, {handler}, {opts}) Parameters: ~ • {name} (`string`) Name of the predicate, without leading # - • {handler} (`fun(match: table<integer,TSNode[]>, pattern: integer, source: integer|string, predicate: any[], metadata: table)`) + • {handler} (`fun(match: table<integer,TSNode[]>, pattern: integer, source: integer|string, predicate: any[], metadata: vim.treesitter.query.TSMetadata)`) • see |vim.treesitter.query.add_directive()| for argument meanings - • {opts} (`table`) A table with the following fields: + • {opts} (`table?`) A table with the following fields: • {force}? (`boolean`) Override an existing predicate of the same name • {all}? (`boolean`) Use the correct implementation of the match table where capture IDs map to a list of nodes - instead of a single node. Defaults to false (for backward - compatibility). This option will eventually become the - default and removed. + instead of a single node. Defaults to true. This option + will be removed in a future release. edit({lang}) *vim.treesitter.query.edit()* Opens a live editor to query the buffer you started from. @@ -1200,14 +1368,8 @@ Query:iter_matches({node}, {source}, {start}, {stop}, {opts}) indices to a list of nodes, and metadata from any directives processing the match. - WARNING: Set `all=true` to ensure all matching nodes in a match are - returned, otherwise only the last node in a match is returned, breaking - captures involving quantifiers such as `(comment)+ @comment`. The default - option `all=false` is only provided for backward compatibility and will be - removed after Nvim 0.10. - Example: >lua - for pattern, match, metadata in cquery:iter_matches(tree:root(), bufnr, 0, -1, { all = true }) do + for pattern, match, metadata in cquery:iter_matches(tree:root(), bufnr, 0, -1) do for id, nodes in pairs(match) do local name = query.captures[id] for _, node in ipairs(nodes) do @@ -1232,16 +1394,15 @@ Query:iter_matches({node}, {source}, {start}, {stop}, {opts}) start depth for each match. This is used to prevent traversing too deep into a tree. • match_limit (integer) Set the maximum number of - in-progress matches (Default: 256). - • all (boolean) When set, the returned match table maps - capture IDs to a list of nodes. Older versions of - iter_matches incorrectly mapped capture IDs to a single - node, which is incorrect behavior. This option will - eventually become the default and removed. + in-progress matches (Default: 256). all (boolean) When + `false` (default `true`), the returned table maps capture + IDs to a single (last) node instead of the full list of + matching nodes. This option is only for backward + compatibility and will be removed in a future release. Return: ~ - (`fun(): integer, table<integer, TSNode[]>, table`) pattern id, match, - metadata + (`fun(): integer, table<integer, TSNode[]>, vim.treesitter.query.TSMetadata`) + pattern id, match, metadata set({lang}, {query_name}, {text}) *vim.treesitter.query.set()* Sets the runtime query named {query_name} for {lang} @@ -1296,7 +1457,11 @@ LanguageTree:contains({range}) *LanguageTree:contains()* Determines whether {range} is contained in the |LanguageTree|. Parameters: ~ - • {range} (`Range4`) `{ start_line, start_col, end_line, end_col }` + • {range} (`table`) A table with the following fields: + • {[1]} (`integer`) start row + • {[2]} (`integer`) start column + • {[3]} (`integer`) end row + • {[4]} (`integer`) end column Return: ~ (`boolean`) @@ -1320,7 +1485,9 @@ LanguageTree:for_each_tree({fn}) *LanguageTree:for_each_tree()* LanguageTree:included_regions() *LanguageTree:included_regions()* Gets the set of included regions managed by this LanguageTree. This can be different from the regions set by injection query, because a partial - |LanguageTree:parse()| drops the regions outside the requested range. + |LanguageTree:parse()| drops the regions outside the requested range. Each + list represents a range in the form of { {start_row}, {start_col}, + {start_bytes}, {end_row}, {end_col}, {end_bytes} }. Return: ~ (`table<integer, Range6[]>`) @@ -1355,7 +1522,11 @@ LanguageTree:language_for_range({range}) Gets the appropriate language that contains {range}. Parameters: ~ - • {range} (`Range4`) `{ start_line, start_col, end_line, end_col }` + • {range} (`table`) A table with the following fields: + • {[1]} (`integer`) start row + • {[2]} (`integer`) start column + • {[3]} (`integer`) end row + • {[4]} (`integer`) end column Return: ~ (`vim.treesitter.LanguageTree`) tree Managing {range} @@ -1365,7 +1536,28 @@ LanguageTree:named_node_for_range({range}, {opts}) Gets the smallest named node that contains {range}. Parameters: ~ - • {range} (`Range4`) `{ start_line, start_col, end_line, end_col }` + • {range} (`table`) A table with the following fields: + • {[1]} (`integer`) start row + • {[2]} (`integer`) start column + • {[3]} (`integer`) end row + • {[4]} (`integer`) end column + • {opts} (`table?`) A table with the following fields: + • {ignore_injections}? (`boolean`, default: `true`) Ignore + injected languages + + Return: ~ + (`TSNode?`) + + *LanguageTree:node_for_range()* +LanguageTree:node_for_range({range}, {opts}) + Gets the smallest node that contains {range}. + + Parameters: ~ + • {range} (`table`) A table with the following fields: + • {[1]} (`integer`) start row + • {[2]} (`integer`) start column + • {[3]} (`integer`) end row + • {[4]} (`integer`) end column • {opts} (`table?`) A table with the following fields: • {ignore_injections}? (`boolean`, default: `true`) Ignore injected languages @@ -1426,7 +1618,11 @@ LanguageTree:tree_for_range({range}, {opts}) Gets the tree that contains {range}. Parameters: ~ - • {range} (`Range4`) `{ start_line, start_col, end_line, end_col }` + • {range} (`table`) A table with the following fields: + • {[1]} (`integer`) start row + • {[2]} (`integer`) start column + • {[3]} (`integer`) end row + • {[4]} (`integer`) end column • {opts} (`table?`) A table with the following fields: • {ignore_injections}? (`boolean`, default: `true`) Ignore injected languages diff --git a/runtime/doc/term.txt b/runtime/doc/tui.txt index 8ef8675d13..9493f91b1e 100644 --- a/runtime/doc/term.txt +++ b/runtime/doc/tui.txt @@ -1,4 +1,4 @@ -*term.txt* Nvim +*tui.txt* Nvim NVIM REFERENCE MANUAL @@ -6,28 +6,45 @@ Terminal UI *TUI* *tui* -Nvim uses a list of terminal capabilities to display its user interface -(except in |--embed| and |--headless| modes). If that information is wrong, -the screen may be messed up or keys may not be recognized. +By default when you run `nvim` (without |--embed| or |--headless|) it starts +the builtin "terminal UI" (TUI). This default UI is optional: you can run Nvim +as a "headless" server, or you can use a |GUI|. Type |gO| to see the table of contents. ============================================================================== -Startup *startup-terminal* +Startup *startup-tui* *startup-terminal* + +Nvim has a client-server architecture: by default when you run `nvim`, this +starts the builtin UI client, which starts a `nvim --embed` server (child) +process that the UI client connects to. After attaching to the server, the UI +client calls |nvim_set_client_info()| (as recommended for all UIs |dev-ui|) +and sets these fields on its channel: > + + client = { + attributes = { + license = 'Apache 2', + pid = …, + website = 'https://neovim.io', + }, + name = 'nvim-tui', + type = 'ui', + version = { … }, + } Nvim guesses the terminal type when it starts (except in |--embed| and |--headless| modes). The |$TERM| environment variable is the primary hint that determines the terminal type. *terminfo* *E557* *E558* *E559* -The terminfo database is used if available. - -The Unibilium library (used by Nvim to read terminfo) allows you to override -the system terminfo with one in $HOME/.terminfo/ directory, in part or in -whole. - -Building your own terminfo is usually as simple as running this as -a non-superuser: +To display its user interface, Nvim reads a list of "terminal capabilities" +from the system terminfo database (or builtin defaults if terminfo is not +found). If that information is wrong, the screen may be messed up or keys may +not be recognized. + +The Unibilium library (used to read terminfo) allows you to override the +system terminfo with one in the "$HOME/.terminfo/" directory. Building your +own terminfo is usually as simple as running this: > curl -LO https://invisible-island.net/datafiles/current/terminfo.src.gz gunzip terminfo.src.gz @@ -41,6 +58,7 @@ or sub-optimal behavior will result (scrolling quirks, wrong colors, etc.). $TERM is also important because it is forwarded by SSH to the remote session, unlike most other environment variables. +> For this terminal Set $TERM to |builtin-terms| ------------------------------------------------------------------------- anything libvte-based vte, vte-256color Y @@ -61,6 +79,7 @@ unlike most other environment variables. Windows/VTP console vtpcon Y Windows/legacy console win32con Y xterm or compatible xterm, xterm-256color Y +< *builtin-terms* *builtin_terms* If a |terminfo| database is not available or there is no entry for the current @@ -126,27 +145,27 @@ extended keys a.k.a. "modifyOtherKeys" or "CSI u") can also be parsed. For example, when running Nvim in tmux, this makes Nvim leave Insert mode and go to the window below: > - tmux send-keys 'Escape' [ 2 7 u 'C-W' j + tmux send-keys 'Escape' [ 2 7 u 'C-W' j Where `'Escape' [ 2 7 u` is an unambiguous "CSI u" sequence for the <Esc> key. The kitty keyboard protocol https://sw.kovidgoyal.net/kitty/keyboard-protocol/ is partially supported, including keypad keys in Unicode Private Use Area. For example, this sequence is recognized by Nvim as <C-kEnter>: > - CSI 57414 ; 5 u + CSI 57414 ; 5 u and can be used differently from <C-CR> in mappings. *tui-modifyOtherKeys* *tui-csiu* At startup Nvim will query your terminal to see if it supports the "CSI u" encoding by writing the sequence > - CSI ? u CSI c + CSI ? u CSI c If your terminal emulator responds with > - CSI ? <flags> u + CSI ? <flags> u this means your terminal supports the "CSI u" encoding and Nvim will tell your terminal to enable it by writing the sequence > - CSI > 1 u + CSI > 1 u If your terminal does not support "CSI u" then Nvim will instead enable the "modifyOtherKeys" encoding by writing the sequence > - CSI > 4 ; 2 m + CSI > 4 ; 2 m When Nvim exits cleanly it will send the corresponding sequence to disable the special key encoding. If Nvim does not exit cleanly then your terminal @@ -215,9 +234,9 @@ are not in terminfo you must add them by setting "terminal-overrides" in See the tmux(1) manual page for the details of how and what to do in the tmux configuration file. It will look something like: >bash - set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q' -<or (alas!) for Konsole 18.07.70 or older, something more complex like: >bash - set -ga terminal-overrides 'xterm*:\E]50;CursorShape=%?%p1%{3}%<%t%{0}%e%{1}%;%d\007' + set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q' +or (alas!) for Konsole 18.07.70 or older, something more complex like: >bash + set -ga terminal-overrides 'xterm*:\E]50;CursorShape=%?%p1%{3}%<%t%{0}%e%{1}%;%d\007' < ============================================================================== Window size *window-size* @@ -250,12 +269,11 @@ number of lines that Vim uses with the command "z{height}<CR>". If the characters from the terminal are arriving with more than 1 second between them you might want to set the 'timeout' and/or 'ttimeout' option. -See the "Options" chapter |options|. If you are using a color terminal that is slow when displaying lines beyond the end of a buffer, this is because Nvim is drawing the whitespace twice, in two sets of colours and attributes. To prevent this, use this command: >vim - hi NonText cterm=NONE ctermfg=NONE + hi NonText cterm=NONE ctermfg=NONE This draws the spaces with the default colours and attributes, which allows the second pass of drawing to be optimized away. Note: Although in theory the colours of whitespace are immaterial, in practice they change the colours of @@ -268,57 +286,65 @@ Using the mouse *mouse-using* *mouse-mode-table* *mouse-overview* Overview of what the mouse buttons do, when 'mousemodel' is "extend": -Normal Mode: -event position selection change action ~ - cursor window ~ -<LeftMouse> yes end yes -<C-LeftMouse> yes end yes "CTRL-]" (2) -<S-LeftMouse> yes no change yes "*" (2) *<S-LeftMouse>* -<LeftDrag> yes start or extend (1) no *<LeftDrag>* -<LeftRelease> yes start or extend (1) no -<MiddleMouse> yes if not active no put -<MiddleMouse> yes if active no yank and put -<RightMouse> yes start or extend yes -<A-RightMouse> yes start or extend blockw. yes *<A-RightMouse>* -<S-RightMouse> yes no change yes "#" (2) *<S-RightMouse>* -<C-RightMouse> no no change no "CTRL-T" -<RightDrag> yes extend no *<RightDrag>* -<RightRelease> yes extend no *<RightRelease>* - -Insert or Replace Mode: -event position selection change action ~ - cursor window ~ -<LeftMouse> yes (cannot be active) yes -<C-LeftMouse> yes (cannot be active) yes "CTRL-O^]" (2) -<S-LeftMouse> yes (cannot be active) yes "CTRL-O*" (2) -<LeftDrag> yes start or extend (1) no like CTRL-O (1) -<LeftRelease> yes start or extend (1) no like CTRL-O (1) -<MiddleMouse> no (cannot be active) no put register -<RightMouse> yes start or extend yes like CTRL-O -<A-RightMouse> yes start or extend blockw. yes -<S-RightMouse> yes (cannot be active) yes "CTRL-O#" (2) -<C-RightMouse> no (cannot be active) no "CTRL-O CTRL-T" - -In a help window: -event position selection change action ~ - cursor window ~ -<2-LeftMouse> yes (cannot be active) no "^]" (jump to help tag) + *<S-LeftMouse>* *<A-RightMouse>* *<S-RightMouse>* *<RightDrag>* + *<RightRelease>* *<LeftDrag>* +Normal Mode: > + event position selection change action + cursor window + --------------------------------------------------------------------------- + <LeftMouse> yes end yes + <C-LeftMouse> yes end yes "CTRL-]" (2) + <S-LeftMouse> yes no change yes "*" (2) + <LeftDrag> yes start or extend (1) no + <LeftRelease> yes start or extend (1) no + <MiddleMouse> yes if not active no put + <MiddleMouse> yes if active no yank and put + <RightMouse> yes start or extend yes + <A-RightMouse> yes start or extend blockw. yes + <S-RightMouse> yes no change yes "#" (2) + <C-RightMouse> no no change no "CTRL-T" + <RightDrag> yes extend no + <RightRelease> yes extend no + +Insert or Replace Mode: > + event position selection change action + cursor window + --------------------------------------------------------------------------- + <LeftMouse> yes (cannot be active) yes + <C-LeftMouse> yes (cannot be active) yes "CTRL-O^]" (2) + <S-LeftMouse> yes (cannot be active) yes "CTRL-O*" (2) + <LeftDrag> yes start or extend (1) no like CTRL-O (1) + <LeftRelease> yes start or extend (1) no like CTRL-O (1) + <MiddleMouse> no (cannot be active) no put register + <RightMouse> yes start or extend yes like CTRL-O + <A-RightMouse> yes start or extend blockw. yes + <S-RightMouse> yes (cannot be active) yes "CTRL-O#" (2) + <C-RightMouse> no (cannot be active) no "CTRL-O CTRL-T" + +In a help window: > + event position selection change action + cursor window + --------------------------------------------------------------------------- + <2-LeftMouse> yes (cannot be active) no "^]" (jump to help tag) When 'mousemodel' is "popup", these are different: -Normal Mode: -event position selection change action ~ - cursor window ~ -<S-LeftMouse> yes start or extend (1) no -<A-LeftMouse> yes start or extend blockw. no *<A-LeftMouse>* -<RightMouse> no popup menu no - -Insert or Replace Mode: -event position selection change action ~ - cursor window ~ -<S-LeftMouse> yes start or extend (1) no like CTRL-O (1) -<A-LeftMouse> yes start or extend blockw. no -<RightMouse> no popup menu no + *<A-LeftMouse>* +Normal Mode: > + event position selection change action + cursor window + --------------------------------------------------------------------------- + <S-LeftMouse> yes start or extend (1) no + <A-LeftMouse> yes start/extend blockw no + <RightMouse> no popup menu no + +Insert or Replace Mode: > + event position selection change action + cursor window + --------------------------------------------------------------------------- + <S-LeftMouse> yes start or extend (1) no like CTRL-O (1) + <A-LeftMouse> yes start/extend blockw no + <RightMouse> no popup menu no (1) only if mouse pointer moved since press (2) only if click is in same buffer @@ -348,16 +374,20 @@ key pressed causes the Visual area to become blockwise. When 'mousemodel' is work on systems where the window manager consumes the mouse events when the alt key is pressed (it may move the window). - *double-click* + *double-click* *<2-LeftMouse>* *<3-LeftMouse>* *<4-LeftMouse>* Double, triple and quadruple clicks are supported when the GUI is active, for Win32 and for an xterm. For selecting text, extra clicks extend the -selection: - click select ~ - double word or % match *<2-LeftMouse>* - triple line *<3-LeftMouse>* - quadruple rectangular block *<4-LeftMouse>* +selection: > + + click select + --------------------------------- + double word or % match + triple line + quadruple rectangular block + Exception: In a Help window a double click jumps to help for the word that is clicked on. + A double click on a word selects that word. 'iskeyword' is used to specify which characters are included in a word. A double click on a character that has a match selects until that match (like using "v%"). If the match is @@ -365,7 +395,7 @@ an #if/#else/#endif block, the selection becomes linewise. For MS-Windows and xterm the time for double clicking can be set with the 'mousetime' option. For the other systems this time is defined outside of Vim. An example, for using a double click to jump to the tag under the cursor: >vim - :map <2-LeftMouse> :exe "tag " .. expand("<cword>")<CR> + :map <2-LeftMouse> :exe "tag " .. expand("<cword>")<CR> Dragging the mouse with a double click (button-down, button-up, button-down and then drag) will result in whole words to be selected. This continues @@ -379,59 +409,62 @@ temporarily. When Visual or Select mode ends, it returns to Insert mode. This is like using CTRL-O in Insert mode. Select mode is used when the 'selectmode' option contains "mouse". - *<MiddleRelease>* *<MiddleDrag>* -Mouse clicks can be mapped. The codes for mouse clicks are: - code mouse button normal action ~ - <LeftMouse> left pressed set cursor position - <LeftDrag> left moved while pressed extend selection - <LeftRelease> left released set selection end - <MiddleMouse> middle pressed paste text at cursor position - <MiddleDrag> middle moved while pressed - - <MiddleRelease> middle released - - <RightMouse> right pressed extend selection - <RightDrag> right moved while pressed extend selection - <RightRelease> right released set selection end - <X1Mouse> X1 button pressed - *X1Mouse* - <X1Drag> X1 moved while pressed - *X1Drag* - <X1Release> X1 button release - *X1Release* - <X2Mouse> X2 button pressed - *X2Mouse* - <X2Drag> X2 moved while pressed - *X2Drag* - <X2Release> X2 button release - *X2Release* + *X1Mouse* *X1Drag* *X1Release* + *X2Mouse* *X2Drag* *X2Release* + *<MiddleRelease>* *<MiddleDrag>* +Mouse clicks can be mapped. The codes for mouse clicks are: > + code mouse button normal action + --------------------------------------------------------------------------- + <LeftMouse> left pressed set cursor position + <LeftDrag> left moved while pressed extend selection + <LeftRelease> left released set selection end + <MiddleMouse> middle pressed paste text at cursor position + <MiddleDrag> middle moved while pressed - + <MiddleRelease> middle released - + <RightMouse> right pressed extend selection + <RightDrag> right moved while pressed extend selection + <RightRelease> right released set selection end + <X1Mouse> X1 button pressed - + <X1Drag> X1 moved while pressed - + <X1Release> X1 button release - + <X2Mouse> X2 button pressed - + <X2Drag> X2 moved while pressed - + <X2Release> X2 button release - The X1 and X2 buttons refer to the extra buttons found on some mice. The 'Microsoft Explorer' mouse has these buttons available to the right thumb. Currently X1 and X2 only work on Win32 and X11 environments. Examples: >vim - :noremap <MiddleMouse> <LeftMouse><MiddleMouse> + :noremap <MiddleMouse> <LeftMouse><MiddleMouse> Paste at the position of the middle mouse button click (otherwise the paste would be done at the cursor position). >vim - :noremap <LeftRelease> <LeftRelease>y + :noremap <LeftRelease> <LeftRelease>y Immediately yank the selection, when using Visual mode. Note the use of ":noremap" instead of "map" to avoid a recursive mapping. >vim - :map <X1Mouse> <C-O> - :map <X2Mouse> <C-I> + :map <X1Mouse> <C-O> + :map <X2Mouse> <C-I> Map the X1 and X2 buttons to go forwards and backwards in the jump list, see |CTRL-O| and |CTRL-I|. *mouse-swap-buttons* To swap the meaning of the left and right mouse buttons: >vim - :noremap <LeftMouse> <RightMouse> - :noremap <LeftDrag> <RightDrag> - :noremap <LeftRelease> <RightRelease> - :noremap <RightMouse> <LeftMouse> - :noremap <RightDrag> <LeftDrag> - :noremap <RightRelease> <LeftRelease> - :noremap g<LeftMouse> <C-RightMouse> - :noremap g<RightMouse> <C-LeftMouse> - :noremap! <LeftMouse> <RightMouse> - :noremap! <LeftDrag> <RightDrag> - :noremap! <LeftRelease> <RightRelease> - :noremap! <RightMouse> <LeftMouse> - :noremap! <RightDrag> <LeftDrag> - :noremap! <RightRelease> <LeftRelease> + :noremap <LeftMouse> <RightMouse> + :noremap <LeftDrag> <RightDrag> + :noremap <LeftRelease> <RightRelease> + :noremap <RightMouse> <LeftMouse> + :noremap <RightDrag> <LeftDrag> + :noremap <RightRelease> <LeftRelease> + :noremap g<LeftMouse> <C-RightMouse> + :noremap g<RightMouse> <C-LeftMouse> + :noremap! <LeftMouse> <RightMouse> + :noremap! <LeftDrag> <RightDrag> + :noremap! <LeftRelease> <RightRelease> + :noremap! <RightMouse> <LeftMouse> + :noremap! <RightDrag> <LeftDrag> + :noremap! <RightRelease> <LeftRelease> < - vim:tw=78:ts=8:ft=help:norl: + vim:et:sw=2:tw=78:ts=8:ft=help:norl: diff --git a/runtime/doc/ui.txt b/runtime/doc/ui.txt index 1f5132bd30..d37cdfb9df 100644 --- a/runtime/doc/ui.txt +++ b/runtime/doc/ui.txt @@ -9,7 +9,7 @@ Nvim UI protocol *UI* *ui* Type |gO| to see the table of contents. ============================================================================== -UI Events *ui-events* +UI Events *ui-protocol* *ui-events* UIs can be implemented as external client processes communicating with Nvim over the RPC API. The default UI model is a terminal-like grid with a single, @@ -398,8 +398,8 @@ numerical highlight ids to the actual attributes. `grid` will not be used anymore and the UI can free any data associated with it. -["grid_cursor_goto", grid, row, column] ~ - Makes `grid` the current grid and `row, column` the cursor position on this +["grid_cursor_goto", grid, row, col] ~ + Makes `grid` the current grid and `row, col` the cursor position on this grid. This event will be sent at most once in a `redraw` batch and indicates the visible cursor position. @@ -610,7 +610,7 @@ tabs. size). If the window was previously hidden, it should now be shown again. -["win_float_pos", grid, win, anchor, anchor_grid, anchor_row, anchor_col, focusable] ~ +["win_float_pos", grid, win, anchor, anchor_grid, anchor_row, anchor_col, focusable, zindex] ~ Display or reconfigure floating window `win`. The window should be displayed above another grid `anchor_grid` at the specified position `anchor_row` and `anchor_col`. For the meaning of `anchor` and more diff --git a/runtime/doc/undo.txt b/runtime/doc/undo.txt index 3fcc196250..b3a49dbb7e 100644 --- a/runtime/doc/undo.txt +++ b/runtime/doc/undo.txt @@ -165,13 +165,13 @@ This is explained in the user manual: |usr_32.txt|. g- Go to older text state. With a count repeat that many times. *:ea* *:earlier* -:earlier {count} Go to older text state {count} times. -:earlier {N}s Go to older text state about {N} seconds before. -:earlier {N}m Go to older text state about {N} minutes before. -:earlier {N}h Go to older text state about {N} hours before. -:earlier {N}d Go to older text state about {N} days before. +:ea[rlier] {count} Go to older text state {count} times. +:ea[rlier] {N}s Go to older text state about {N} seconds before. +:ea[rlier] {N}m Go to older text state about {N} minutes before. +:ea[rlier] {N}h Go to older text state about {N} hours before. +:ea[rlier] {N}d Go to older text state about {N} days before. -:earlier {N}f Go to older text state {N} file writes before. +:ea[rlier] {N}f Go to older text state {N} file writes before. When changes were made since the last write ":earlier 1f" will revert the text to the state when it was written. Otherwise it will go to the write @@ -184,13 +184,13 @@ g- Go to older text state. With a count repeat that many g+ Go to newer text state. With a count repeat that many times. *:lat* *:later* -:later {count} Go to newer text state {count} times. -:later {N}s Go to newer text state about {N} seconds later. -:later {N}m Go to newer text state about {N} minutes later. -:later {N}h Go to newer text state about {N} hours later. -:later {N}d Go to newer text state about {N} days later. +:lat[er] {count} Go to newer text state {count} times. +:lat[er] {N}s Go to newer text state about {N} seconds later. +:lat[er] {N}m Go to newer text state about {N} minutes later. +:lat[er] {N}h Go to newer text state about {N} hours later. +:lat[er] {N}d Go to newer text state about {N} days later. -:later {N}f Go to newer text state {N} file writes later. +:lat[er] {N}f Go to newer text state {N} file writes later. When at the state of the last file write, ":later 1f" will go to the newest text state. diff --git a/runtime/doc/usr_05.txt b/runtime/doc/usr_05.txt index 076a50c582..698d1207d3 100644 --- a/runtime/doc/usr_05.txt +++ b/runtime/doc/usr_05.txt @@ -120,7 +120,7 @@ This switches on three very clever mechanisms: *restore-cursor* *last-position-jump* > augroup RestoreCursor autocmd! - autocmd BufRead * autocmd FileType <buffer> ++once + autocmd BufReadPre * autocmd FileType <buffer> ++once \ let s:line = line("'\"") \ | if s:line >= 1 && s:line <= line("$") && &filetype !~# 'commit' \ && index(['xxd', 'gitrebase'], &filetype) == -1 @@ -234,6 +234,22 @@ an archive or as a repository. For an archive you can follow these steps: Here "fancytext" is the name of the package, it can be anything else. + +Adding nohlsearch package *nohlsearch-install* + +Load the plugin with this command: > + packadd nohlsearch +< +Automatically execute |:nohlsearch| after 'updatetime' or getting into +|Insert| mode. +Thus assuming default updatetime, hlsearch would be suspended/turned off after +4 seconds of idle time. + +To disable the effect of the plugin after it has been loaded: > + au! nohlsearch +< + + More information about packages can be found here: |packages|. ============================================================================== diff --git a/runtime/doc/usr_21.txt b/runtime/doc/usr_21.txt index 4ae72bbe84..8671f04ba2 100644 --- a/runtime/doc/usr_21.txt +++ b/runtime/doc/usr_21.txt @@ -303,21 +303,21 @@ use, and save this in a session. Then you can go back to this layout whenever you want. For example, this is a nice layout to use: > - +----------------------------------------+ - | VIM - main help file | - | | - |Move around: Use the cursor keys, or "h| - |help.txt================================| - |explorer | | - |dir |~ | - |dir |~ | - |file |~ | - |file |~ | - |file |~ | - |file |~ | - |~/=========|[No File]===================| - | | - +----------------------------------------+ + +----------------------------------------+ + | VIM - main help file | + | | + |Move around: Use the cursor keys, or "h| + |help.txt================================| + |explorer | | + |dir |~ | + |dir |~ | + |file |~ | + |file |~ | + |file |~ | + |file |~ | + |~/=========|[No File]===================| + | | + +----------------------------------------+ < This has a help window at the top, so that you can read this text. The narrow vertical window on the left contains a file explorer. This is a Vim plugin @@ -448,9 +448,9 @@ trust the files you are editing: > :set nomodeline -Use this format for the modeline: +Use this format for the modeline: > - any-text vim:set {option}={value} ... : any-text ~ + any-text vim:set {option}={value} ... : any-text The "any-text" indicates that you can put any text before and after the part that Vim will use. This allows making it look like a comment, like what was @@ -462,9 +462,9 @@ using something like "gvim:" will not work. typing the ":set" command, except that you need to insert a backslash before a colon (otherwise it would be seen as the end of the modeline). -Another example: +Another example: > - // vim:set textwidth=72 dir=c\:\tmp: use c:\tmp here ~ + // vim:set textwidth=72 dir=c\:\tmp: use c:\tmp here There is an extra backslash before the first colon, so that it's included in the ":set" command. The text after the second colon is ignored, thus a remark diff --git a/runtime/doc/usr_29.txt b/runtime/doc/usr_29.txt index dd8598a3a0..eb20f7b6f2 100644 --- a/runtime/doc/usr_29.txt +++ b/runtime/doc/usr_29.txt @@ -34,7 +34,7 @@ following command: > "ctags" is a separate program. Most Unix systems already have it installed. If you do not have it yet, you can find Universal ctags at: - https://ctags.io ~ + https://ctags.io Universal ctags is preferred, Exuberant ctags is no longer being developed. @@ -87,7 +87,7 @@ The ":tags" command shows the list of tags that you traversed through: 1 1 write_line 8 write_block.c ~ 2 1 write_char 7 write_line.c ~ > ~ -> +< Now to go back. The CTRL-T command goes to the preceding tag. In the example above you get back to the "write_line" function, in the call to "write_char". This command takes a count argument that indicates how many tags to jump diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index ab2eecdfaf..8c7ed875cf 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -836,6 +836,7 @@ System functions and manipulation of files: getfperm() get the permissions of a file setfperm() set the permissions of a file getftype() get the kind of a file + isabsolutepath() check if a path is absolute isdirectory() check if a directory exists getfsize() get the size of a file getcwd() get the current working directory @@ -855,6 +856,7 @@ System functions and manipulation of files: readblob() read a file into a Blob readdir() get a List of file names in a directory writefile() write a List of lines or Blob into a file + filecopy() copy a file {from} to {to} Date and Time: *date-functions* *time-functions* getftime() get last modification time of a file @@ -906,7 +908,8 @@ Buffers, windows and the argument list: Command line: *command-line-functions* getcmdcompltype() get the type of the current command line completion - getcmdline() get the current command line + getcmdline() get the current command line input + getcmdprompt() get the current command line prompt getcmdpos() get position of the cursor in the command line getcmdscreenpos() get screen position of the cursor in the command line diff --git a/runtime/doc/usr_toc.txt b/runtime/doc/usr_toc.txt index dd0d5784f5..d1770ddcd5 100644 --- a/runtime/doc/usr_toc.txt +++ b/runtime/doc/usr_toc.txt @@ -2,12 +2,12 @@ VIM USER MANUAL - by Bram Moolenaar - Table Of Contents *user-manual* + Table Of Contents *user-manual* *usr* ============================================================================== Overview -Getting Started +Getting Started ~ |usr_01.txt| About the manuals |usr_02.txt| The first steps in Vim |usr_03.txt| Moving around @@ -21,7 +21,7 @@ Getting Started |usr_11.txt| Recovering from a crash |usr_12.txt| Clever tricks -Editing Effectively +Editing Effectively ~ |usr_20.txt| Typing command-line commands quickly |usr_21.txt| Go away and come back |usr_22.txt| Finding the file to edit @@ -36,7 +36,7 @@ Editing Effectively |usr_31.txt| Exploiting the GUI |usr_32.txt| The undo tree -Tuning Vim +Tuning Vim ~ |usr_40.txt| Make new commands |usr_41.txt| Write a Vim script |usr_42.txt| Add new menus @@ -45,7 +45,7 @@ Tuning Vim |usr_45.txt| Select your language (locale) -Reference manual +Reference manual ~ |reference_toc| More detailed information for all commands The user manual is online: diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index 0287271d4c..33da539c66 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -28,8 +28,8 @@ CTRL-L Clears and redraws the screen. The redraw may happen :redr[aw][!] Redraws pending screen updates now, or the entire screen if "!" is included. To CLEAR the screen use |:mode| or |CTRL-L|. - Useful to update the screen during a script or - function (or a mapping if 'lazyredraw' set). + It can be used to redraw the screen in a script + or function (or a mapping if |'lazyredraw'| is set). See also |nvim__redraw()|. *:redraws* *:redrawstatus* @@ -78,10 +78,9 @@ ga Print the ascii value of the character under the If the character can be inserted as a digraph, also output the two characters that can be used to create the character: - <ö> 246, Hex 00f6, Oct 366, Digr o: ~ + <ö> 246, Hex 00f6, Oct 366, Digr o: ~ This shows you can type CTRL-K o : to insert ö. - *g8* g8 Print the hex values of the bytes used in the character under the cursor, assuming it is in |UTF-8| @@ -140,12 +139,18 @@ gx Opens the current filepath or URL (decided by :[range]# [count] [flags] synonym for :number. - *:#!* + *:#!* *vim-shebang* :#!{anything} Ignored, so that you can start a Vim script with: > #!vim -S - echo "this is a Vim script" - quit + let mylogbook='$HOME/logbook.md' + exe $':e {mylogbook}' + $ + put ='## ' .. strftime('%d. %b %Y') + norm! o < + Make that script executable and run it to create a + new diary entry. + *:z* *E144* :[range]z[+-^.=][count] Display several lines of text surrounding the line specified with [range], or around the current line @@ -209,7 +214,7 @@ gx Opens the current filepath or URL (decided by This implies that an insert command must be completed (to start Insert mode, see |:startinsert|). A ":" command must be completed as well. And you can't use - "Q" or "gQ" to start Ex mode. + "gQ" to start Ex mode. The display is not updated while ":normal" is busy. diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 5d894bb5e1..e069678b30 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -62,11 +62,12 @@ Defaults *nvim-defaults* - 'isfname' does not include ":" (on Windows). Drive letters are handled correctly without it. (Use |gF| for filepaths suffixed with ":line:col"). - 'joinspaces' is disabled +- 'jumpoptions' defaults to "clean" - 'langnoremap' is enabled - 'langremap' is disabled - 'laststatus' defaults to 2 (statusline is always shown) - 'listchars' defaults to "tab:> ,trail:-,nbsp:+" -- 'mouse' defaults to "nvi" +- 'mouse' defaults to "nvi", see |default-mouse| for details - 'mousemodel' defaults to "popup_setpos" - 'nrformats' defaults to "bin,hex" - 'path' defaults to ".,,". The C ftplugin adds "/usr/include" if it exists. @@ -100,28 +101,35 @@ Defaults *nvim-defaults* DEFAULT MOUSE *default-mouse* *disable-mouse* -By default the mouse is enabled, and <RightMouse> opens a |popup-menu| with -standard actions ("Cut", "Copy", "Paste", …). Mouse is NOT enabled in -|command-mode| or the |more-prompt|, so you can temporarily disable it just by -typing ":". +By default the mouse is enabled. This means |scroll-mouse-wheel| will scroll +the window instead of moving the cursor; <LeftMouse> click places the cursor; +and <RightMouse> click opens the default |popup-menu| with standard actions. + +Mouse is NOT enabled in |Cmdline-mode| or the |more-prompt|, so you can +temporarily disable it just by typing ":". Or if you want to partially or +fully disable the mouse or popup-menu, do any of the following: -If you don't like this you can disable the mouse in your |config| using any of -the following: - Disable mouse completely by unsetting the 'mouse' option: >vim set mouse= -- Pressing <RightMouse> extends selection instead of showing popup-menu: >vim +- Change the 'mousemodel', so <RightMouse> extends selection instead of + showing the popup-menu: >vim set mousemodel=extend -- Pressing <A-LeftMouse> releases mouse until the cursor moves: >vim +- Map <A-LeftMouse> so that it temporarily disables mouse until the cursor + moves: >vim nnoremap <A-LeftMouse> <Cmd> \ set mouse=<Bar> \ echo 'mouse OFF until next cursor-move'<Bar> \ autocmd CursorMoved * ++once set mouse&<Bar> \ echo 'mouse ON'<CR> < -To remove the "How-to disable mouse" menu item and the separator above it: >vim +To remove the default popup-menu without disabling mouse: >vim + aunmenu PopUp + autocmd! nvim_popupmenu + +To remove only the "How-to disable mouse" menu item (and its separator): >vim aunmenu PopUp.How-to\ disable\ mouse - aunmenu PopUp.-1- -< + aunmenu PopUp.-2- + DEFAULT MAPPINGS *default-mappings* Nvim creates the following default mappings at |startup|. You can disable any @@ -145,7 +153,14 @@ of these in your config by simply removing the mapping, e.g. ":unmap Y". - <C-S> |i_CTRL-S| - ]d |]d-default| - [d |[d-default| +- [D |[D-default| +- ]D |]D-default| - <C-W>d |CTRL-W_d-default| +- |[q|, |]q|, |[Q|, |]Q|, |[CTRL-Q|, |]CTRL-Q| +- |[l|, |]l|, |[L|, |]L|, |[CTRL-L|, |]CTRL-L| +- |[t|, |]t|, |[T|, |]T|, |[CTRL-T|, |]CTRL-T| +- |[a|, |]a|, |[A|, |]A| +- |[b|, |]b|, |[B|, |]B| - Nvim LSP client defaults |lsp-defaults| - K |K-lsp-default| @@ -164,6 +179,14 @@ nvim_terminal: when 'background' is "light". While this may not reflect the actual foreground/background color, it permits 'background' to be retained for a nested Nvim instance running in the terminal emulator. +- TermOpen: Sets default options for |terminal| buffers: + - 'nomodifiable' + - 'undolevels' set to -1 + - 'textwidth' set to 0 + - 'nowrap' + - 'nolist' + - 'winhighlight' uses |hl-StatusLineTerm| and |hl-StatusLineTermNC| in + place of |hl-StatusLine| and |hl-StatusLineNC| nvim_cmdwin: - CmdwinEnter: Limits syntax sync to maxlines=1 in the |cmdwin|. @@ -330,7 +353,9 @@ string options work. - 'guicursor' works in the terminal (TUI) - 'inccommand' shows interactive results for |:substitute|-like commands and |:command-preview| commands -- 'jumpoptions' "view" tries to restore the |mark-view| when moving through +- 'jumpoptions' + - "view" tries to restore |mark-view| when moving through the jumplist. + - "clean" removes unloaded buffers from the jumplist. - the |jumplist|, |changelist|, |alternate-file| or using |mark-motions|. - 'laststatus' global statusline support - 'mousescroll' amount to scroll by when scrolling with a mouse @@ -529,13 +554,13 @@ Functions: Highlight groups: - |hl-ColorColumn|, |hl-CursorColumn| are lower priority than most other groups -- |hl-CurSearch| highlights match under cursor instead of last match found - using |n| or |N| - |hl-CursorLine| is low-priority unless foreground color is set - |hl-VertSplit| superseded by |hl-WinSeparator| - Highlight groups names are allowed to contain `@` characters. - It is an error to define a highlight group with a name that doesn't match the regexp `[a-zA-Z0-9_.@-]*` (see |group-name|). +- |hl-StatusLineTerm| |hl-StatusLineTermNC| are implemented as 'winhighlight' + window-local highlights which are set by the default |TermOpen| handler. Macro (|recording|) behavior: - Replay of a macro recorded during :lmap produces the same actions as when it @@ -663,17 +688,6 @@ Events: - *SafeStateAgain* - *SigUSR1* Use |Signal| to detect `SIGUSR1` signal instead. -Highlight groups: -- *hl-StatusLineTerm* *hl-StatusLineTermNC* are unnecessary because Nvim - supports 'winhighlight' window-local highlights. For example, to mimic Vim's - StatusLineTerm: >vim - hi StatusLineTerm ctermfg=black ctermbg=green - hi StatusLineTermNC ctermfg=green - autocmd TermOpen,WinEnter * if &buftype=='terminal' - \|setlocal winhighlight=StatusLine:StatusLineTerm,StatusLineNC:StatusLineTermNC - \|else|setlocal winhighlight=|endif -< - Options: - *'aleph'* *'al'* - antialias diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt index 4791e73929..5729dd0874 100644 --- a/runtime/doc/windows.txt +++ b/runtime/doc/windows.txt @@ -53,11 +53,27 @@ active yes yes 'a' hidden no yes 'h' inactive no no ' ' -Note: All CTRL-W commands can also be executed with |:wincmd|, for those -places where a Normal mode command can't be used or is inconvenient. + *buffer-reuse* +Each buffer has a unique number and the number will not change within a Vim +session. The |bufnr()| and |bufname()| functions can be used to convert +between a buffer name and the buffer number. There is one exception: if a new +empty buffer is created and it is not modified, the buffer will be re-used +when loading another file into that buffer. This also means the buffer number +will not change. The main Vim window can hold several split windows. There are also tab pages |tab-page|, each of which can hold multiple windows. + + *focusable* +If a window is focusable, it is part of the "navigation stack", that is, +editor commands such as :windo, |CTRL-W|, etc., will consider the window as +one that can be made the "current window". A non-focusable window will be +skipped by such commands (though it can be explicitly focused by +|nvim_set_current_win()|). + +Windows (especially floating windows) can have many other |api-win_config| +properties such as "hide" and "fixed" which also affect behavior. + *window-ID* *winid* *windowid* Each window has a unique identifier called the window ID. This identifier will not change within a Vim session. The |win_getid()| and |win_id2tabwin()| @@ -69,9 +85,6 @@ across tabs. For most functions that take a window ID or a window number, the window number only applies to the current tab, while the window ID can refer to a window in any tab. -Each buffer has a unique number and the number will not change within a Vim -session. The |bufnr()| and |bufname()| functions can be used to convert -between a buffer name and the buffer number. ============================================================================== 2. Starting Vim *windows-starting* @@ -423,18 +436,19 @@ CTRL-W l Move cursor to Nth window right of current one. Uses the cursor position to select between alternatives. CTRL-W w *CTRL-W_w* *CTRL-W_CTRL-W* -CTRL-W CTRL-W Without count: move cursor to window below/right of the - current one. If there is no window below or right, go to - top-left window. - With count: go to Nth window (windows are numbered from - top-left to bottom-right). To obtain the window number see - |bufwinnr()| and |winnr()|. When N is larger than the number - of windows go to the last window. +CTRL-W CTRL-W Without count: move cursor to the |focusable| window + below/right of the current one. If there is no (focusable) + window below or right, go to top-left window. With count: go + to Nth window (windows are numbered from top-left to + bottom-right). To obtain the window number see |bufwinnr()| + and |winnr()|. When N is larger than the number of windows go + to the last window. *CTRL-W_W* -CTRL-W W Without count: move cursor to window above/left of current - one. If there is no window above or left, go to bottom-right - window. With count: go to Nth window, like with CTRL-W w. +CTRL-W W Without count: move cursor to the |focusable| window + above/left of current one. If there is no window above or + left, go to bottom-right window. With count: go to Nth + window, like with CTRL-W w. CTRL-W t *CTRL-W_t* *CTRL-W_CTRL-T* CTRL-W CTRL-T Move cursor to top-left window. @@ -468,6 +482,10 @@ These commands can also be executed with ":wincmd": :exe nr .. "wincmd w" < This goes to window "nr". +Note: All CTRL-W commands can also be executed with |:wincmd|, for those +places where a Normal mode command can't be used or is inconvenient (e.g. +in a browser-based terminal). + ============================================================================== 5. Moving windows around *window-moving* @@ -787,9 +805,9 @@ can also get to them with the buffer list commands, like ":bnext". 8. Do a command in all buffers or windows *list-repeat* *:windo* -:[range]windo {cmd} Execute {cmd} in each window or if [range] is given - only in windows for which the window number lies in - the [range]. It works like doing this: > +:[range]windo {cmd} Execute {cmd} in each |focusable| window, or only for + windows in a given [range] of window numbers. It works + like doing this: > CTRL-W t :{cmd} CTRL-W w @@ -1175,11 +1193,12 @@ list of buffers. |unlisted-buffer| :bw[ipeout][!] N1 N2 ... Like |:bdelete|, but really delete the buffer. Everything related to the buffer is lost. All marks in this buffer - become invalid, option settings are lost, etc. Don't use this + become invalid, option settings are lost, the jumplist and + tagstack data will be purged, etc. Don't use this unless you know what you are doing. Examples: > - :.+,$bwipeout " wipe out all buffers after the current - " one - :%bwipeout " wipe out all buffers + :.+,$bwipeout " wipe out all buffers after the current + " one + :%bwipeout " wipe out all buffers < :[N]bun[load][!] *:bun* *:bunload* *E515* :bun[load][!] [N] @@ -1242,7 +1261,7 @@ list of buffers. |unlisted-buffer| :w foobar | sp # < Also see |+cmd|. -:[N]bn[ext][!] [+cmd] [N] *:bn* *:bnext* *E87* +:[N]bn[ext][!] [+cmd] [N] *:bn* *:bnext* *[b* *E87* Go to [N]th next buffer in buffer list. [N] defaults to one. Wraps around the end of the buffer list. See |:buffer-!| for [!]. @@ -1260,7 +1279,7 @@ list of buffers. |unlisted-buffer| Wraps around the end of the buffer list. Uses 'switchbuf' Also see |+cmd|. -:[N]bN[ext][!] [+cmd] [N] *:bN* *:bNext* *:bp* *:bprevious* *E88* +:[N]bN[ext][!] [+cmd] [N] *:bN* *:bNext* *:bp* *:bprevious* *]b* *E88* :[N]bp[revious][!] [+cmd] [N] Go to [N]th previous buffer in buffer list. [N] defaults to one. Wraps around the start of the buffer list. @@ -1274,7 +1293,7 @@ list of buffers. |unlisted-buffer| Uses 'switchbuf'. Also see |+cmd|. -:br[ewind][!] [+cmd] *:br* *:bre* *:brewind* +:br[ewind][!] [+cmd] *:br* *:bre* *:brewind* *[B* Go to first buffer in buffer list. If the buffer list is empty, go to the first unlisted buffer. See |:buffer-!| for [!]. @@ -1292,7 +1311,7 @@ list of buffers. |unlisted-buffer| :sbf[irst] [+cmd] *:sbf* *:sbfirst* Same as ":sbrewind". -:bl[ast][!] [+cmd] *:bl* *:blast* +:bl[ast][!] [+cmd] *:bl* *:blast* *]B* Go to last buffer in buffer list. If the buffer list is empty, go to the last unlisted buffer. See |:buffer-!| for [!]. |