aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc/eval.txt
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/doc/eval.txt')
-rw-r--r--runtime/doc/eval.txt979
1 files changed, 750 insertions, 229 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index eebdabd154..9aa60657e0 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1,4 +1,4 @@
-*eval.txt* For Vim version 7.4. Last change: 2016 Jan 16
+*eval.txt* For Vim version 7.4. Last change: 2016 Aug 27
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -43,11 +43,15 @@ Number A 32 or 64 bit signed number. |expr-number| *Number*
Float A floating point number. |floating-point-format| *Float*
Examples: 123.456 1.15e-6 -1.1e3
+ *E928*
String A NUL terminated string of 8-bit unsigned characters (bytes).
|expr-string| Examples: "ab\txx\"--" 'x-z''a,c'
Funcref A reference to a function |Funcref|.
Example: function("strlen")
+ It can be bound to a dictionary and arguments, it then works
+ like a Partial.
+ Example: function("Callback", [arg], myDict)
List An ordered sequence of items |List|.
Example: [1, 2, ['a', 'b']]
@@ -100,18 +104,12 @@ When mixing Number and Float the Number is converted to Float. Otherwise
there is no automatic conversion of Float. You can use str2float() for String
to Float, printf() for Float to String and float2nr() for Float to Number.
- *E706* *sticky-type-checking*
-You will get an error if you try to change the type of a variable. You need
-to |:unlet| it first to avoid this error. String and Number are considered
-equivalent though, as well are Float and Number. Consider this sequence of
-commands: >
- :let l = "string"
- :let l = 44 " changes type from String to Number
- :let l = [1, 2, 3] " error! l is still a Number
- :let l = 4.4 " changes type from Number to Float
- :let l = "string" " error!
-
+ *E891* *E892* *E893* *E894*
+When expecting a Float a Number can also be used, but nothing else.
+ *no-type-checking*
+You will not get an error if you try to change the type of a variable.
+
1.2 Function references ~
*Funcref* *E695* *E718*
A Funcref variable is obtained with the |function()| function. It can be used
@@ -144,6 +142,40 @@ The name of the referenced function can be obtained with |string()|. >
You can use |call()| to invoke a Funcref and use a list variable for the
arguments: >
:let r = call(Fn, mylist)
+<
+ *Partial*
+A Funcref optionally binds a Dictionary and/or arguments. This is also called
+a Partial. This is created by passing the Dictionary and/or arguments to
+function(). When calling the function the Dictionary and/or arguments will be
+passed to the function. Example: >
+
+ let Cb = function('Callback', ['foo'], myDict)
+ call Cb()
+
+This will invoke the function as if using: >
+ call myDict.Callback('foo')
+
+Note that binding a function to a Dictionary also happens when the function is
+a member of the Dictionary: >
+
+ let myDict.myFunction = MyFunction
+ call myDict.myFunction()
+
+Here MyFunction() will get myDict passed as "self". This happens when the
+"myFunction" member is accessed. When assigning "myFunction" to otherDict
+and calling it, it will be bound to otherDict: >
+
+ let otherDict.myFunction = myDict.myFunction
+ call otherDict.myFunction()
+
+Now "self" will be "otherDict". But when the dictionary was bound explicitly
+this won't happen: >
+
+ let myDict.myFunction = function(MyFunction, myDict)
+ let otherDict.myFunction = myDict.myFunction
+ call otherDict.myFunction()
+
+Here "self" will be "myDict", because it was bound explitly.
1.3 Lists ~
@@ -410,7 +442,8 @@ only appear once. Examples: >
A key is always a String. You can use a Number, it will be converted to a
String automatically. Thus the String '4' and the number 4 will find the same
entry. Note that the String '04' and the Number 04 are different, since the
-Number will be converted to the String '4'.
+Number will be converted to the String '4'. The empty string can be used as a
+key.
A value can be any expression. Using a Dictionary for a value creates a
nested Dictionary: >
@@ -750,22 +783,40 @@ A |Dictionary| can only be compared with a |Dictionary| and only "equal", "not
equal" and "is" can be used. This compares the key/values of the |Dictionary|
recursively. Ignoring case means case is ignored when comparing item values.
- *E693* *E694*
-A |Funcref| can only be compared with a |Funcref| and only "equal" and "not
-equal" can be used. Case is never ignored.
+ *E694*
+A |Funcref| can only be compared with a |Funcref| and only "equal", "not
+equal", "is" and "isnot" can be used. Case is never ignored. Whether
+arguments or a Dictionary are bound (with a partial) matters. The
+Dictionaries must also be equal (or the same, in case of "is") and the
+arguments must be equal (or the same).
+
+To compare Funcrefs to see if they refer to the same function, ignoring bound
+Dictionary and arguments, use |get()| to get the function name: >
+ if get(Part1, 'name') == get(Part2, 'name')
+ " Part1 and Part2 refer to the same function
When using "is" or "isnot" with a |List| or a |Dictionary| this checks if the
expressions are referring to the same |List| or |Dictionary| instance. A copy
of a |List| is different from the original |List|. When using "is" without
a |List| or a |Dictionary| it is equivalent to using "equal", using "isnot"
equivalent to using "not equal". Except that a different type means the
-values are different: "4 == '4'" is true, "4 is '4'" is false and "0 is []" is
-false and not an error. "is#"/"isnot#" and "is?"/"isnot?" can be used to match
-and ignore case.
+values are different: >
+ echo 4 == '4'
+ 1
+ echo 4 is '4'
+ 0
+ echo 0 is []
+ 0
+"is#"/"isnot#" and "is?"/"isnot?" can be used to match and ignore case.
When comparing a String with a Number, the String is converted to a Number,
-and the comparison is done on Numbers. This means that "0 == 'x'" is TRUE,
-because 'x' converted to a Number is zero.
+and the comparison is done on Numbers. This means that: >
+ echo 0 == 'x'
+ 1
+because 'x' converted to a Number is zero. However: >
+ echo 0 == 'x'
+ 0
+Inside a List or Dictionary this conversion is not used.
When comparing two Strings, this is done with strcmp() or stricmp(). This
results in the mathematical difference (comparing byte values), not
@@ -858,11 +909,12 @@ These three can be repeated and mixed. Examples:
expr8 *expr8*
-----
expr8[expr1] item of String or |List| *expr-[]* *E111*
+ *subscript*
If expr8 is a Number or String this results in a String that contains the
expr1'th single byte from expr8. expr8 is used as a String, expr1 as a
Number. This doesn't recognize multi-byte encodings, see |byteidx()| for
-an alternative.
+an alternative, or use `split()` to turn the string into a list of characters.
Index zero gives the first byte. This is like it works in C. Careful:
text column numbers start with one! Example, to get the byte under the
@@ -870,7 +922,7 @@ cursor: >
:let c = getline(".")[col(".") - 1]
If the length of the String is less than the index, the result is an empty
-String. A negative index always results in an empty string (reason: backwards
+String. A negative index always results in an empty string (reason: backward
compatibility). Use [-1:] to get the last byte.
If expr8 is a |List| then it results the item at index expr1. See |list-index|
@@ -1022,8 +1074,8 @@ A string constant accepts these special characters:
\x. byte specified with one hex number (must be followed by non-hex char)
\X.. same as \x..
\X. same as \x.
-\u.... character specified with up to 4 hex numbers, stored according to the
- current value of 'encoding' (e.g., "\u02a4")
+\u.... character specified with up to 4 hex numbers, stored as UTF-8
+ (e.g., "\u02a4")
\U.... same as \u but allows up to 8 hex numbers.
\b backspace <BS>
\e escape <Esc>
@@ -1038,8 +1090,7 @@ A string constant accepts these special characters:
utf-8 character, use \uxxxx as mentioned above.
Note that "\xff" is stored as the byte 255, which may be invalid in some
-encodings. Use "\u00ff" to store character 255 according to the current value
-of 'encoding'.
+encodings. Use "\u00ff" to store character 255 correctly as UTF-8.
Note that "\000" and "\x00" force the end of the string.
@@ -1299,6 +1350,10 @@ v:beval_winnr The number of the window, over which the mouse pointer is. Only
window has number zero (unlike most other places where a
window gets a number).
+ *v:beval_winid* *beval_winid-variable*
+v:beval_winid The window ID of the window, over which the mouse pointer is.
+ Otherwise like v:beval_winnr.
+
*v:char* *char-variable*
v:char Argument for evaluating 'formatexpr' and used for the typed
character when using <expr> in an abbreviation |:map-<expr>|.
@@ -1373,6 +1428,9 @@ v:dying Normally zero. When a deadly signal is caught it's set to
< Note: if another deadly signal is caught when v:dying is one,
VimLeave autocommands will not be executed.
+ *v:exiting* *exiting-variable*
+v:exiting The exit value Nvim will use. Before exiting, it is |v:null|.
+
*v:errmsg* *errmsg-variable*
v:errmsg Last given error message. It's allowed to set this variable.
Example: >
@@ -1420,7 +1478,7 @@ v:exception The value of the exception most recently caught and not
*v:false* *false-variable*
v:false Special value used to put "false" in JSON and msgpack. See
- |json_encode()|. This value is converted to "false" when used
+ |json_encode()|. This value is converted to "v:false" when used
as a String (e.g. in |expr5| with string concatenation
operator) and to zero when used as a Number (e.g. in |expr5|
or |expr7| when used with numeric operators).
@@ -1548,6 +1606,10 @@ v:mouse_win Window number for a mouse click obtained with |getchar()|.
First window has number 1, like with |winnr()|. The value is
zero when there was no mouse button click.
+ *v:mouse_winid* *mouse_winid-variable*
+v:mouse_winid Window ID for a mouse click obtained with |getchar()|.
+ The value is zero when there was no mouse button click.
+
*v:mouse_lnum* *mouse_lnum-variable*
v:mouse_lnum Line number for a mouse click obtained with |getchar()|.
This is the text line number, not the screen line number. The
@@ -1566,7 +1628,7 @@ v:msgpack_types Dictionary containing msgpack types used by |msgpackparse()|
*v:null* *null-variable*
v:null Special value used to put "null" in JSON and NIL in msgpack.
- See |json_encode()|. This value is converted to "null" when
+ See |json_encode()|. This value is converted to "v:null" when
used as a String (e.g. in |expr5| with string concatenation
operator) and to zero when used as a Number (e.g. in |expr5|
or |expr7| when used with numeric operators).
@@ -1650,9 +1712,9 @@ v:scrollstart String describing the script or function that caused the
hit-enter prompt.
*v:servername* *servername-variable*
+ *$NVIM_LISTEN_ADDRESS*
v:servername Default {Nvim} server address. Equivalent to
- |$NVIM_LISTEN_ADDRESS| on startup, but may differ if the
- latter is modified or unset. |serverstop()|
+ |$NVIM_LISTEN_ADDRESS| on startup. |serverstop()|
Read-only.
@@ -1704,6 +1766,21 @@ v:swapcommand Normal mode command to be executed after a file has been
example, when jumping to a tag the value is ":tag tagname\r".
For ":edit +cmd file" the value is ":cmd\r".
+ *v:t_TYPE* *v:t_bool* *t_bool-varialble*
+v:t_bool Value of Boolean type. Read-only. See: |type()|
+ *v:t_dict* *t_dict-varialble*
+v:t_dict Value of Dictionary type. Read-only. See: |type()|
+ *v:t_float* *t_float-varialble*
+v:t_float Value of Float type. Read-only. See: |type()|
+ *v:t_func* *t_func-varialble*
+v:t_func Value of Funcref type. Read-only. See: |type()|
+ *v:t_list* *t_list-varialble*
+v:t_list Value of List type. Read-only. See: |type()|
+ *v:t_number* *t_number-varialble*
+v:t_number Value of Number type. Read-only. See: |type()|
+ *v:t_string* *t_string-varialble*
+v:t_string Value of String type. Read-only. See: |type()|
+
*v:termresponse* *termresponse-variable*
v:termresponse The escape sequence returned by the terminal for the |t_RV|
termcap entry. It is set when Vim receives an escape sequence
@@ -1738,7 +1815,7 @@ v:throwpoint The point where the exception most recently caught and not
*v:true* *true-variable*
v:true Special value used to put "true" in JSON and msgpack. See
- |json_encode()|. This value is converted to "true" when used
+ |json_encode()|. This value is converted to "v:true" when used
as a String (e.g. in |expr5| with string concatenation
operator) and to one when used as a Number (e.g. in |expr5| or
|expr7| when used with numeric operators).
@@ -1759,13 +1836,17 @@ v:version Version number of Vim: Major version number times 100 plus
version 5.0 and 5.1 may have a patch 123, but these are
completely different.
+ *v:vim_did_enter* *vim_did_enter-variable*
+v:vim_did_enter Zero until most of startup is done. It is set to one just
+ before |VimEnter| autocommands are triggered.
+
*v:warningmsg* *warningmsg-variable*
v:warningmsg Last given warning message. It's allowed to set this variable.
*v:windowid* *windowid-variable* {Nvim}
v:windowid Application-specific window ID ("window handle" in MS-Windows)
which may be set by any attached UI. Defaults to zero.
- Note: for windows inside Vim use |winnr()|.
+ Note: for windows inside Vim use |winnr()| or |win_getid()|.
==============================================================================
4. Builtin Functions *functions*
@@ -1780,6 +1861,7 @@ abs({expr}) Float or Number absolute value of {expr}
acos({expr}) Float arc cosine of {expr}
add({list}, {item}) List append {item} to |List| {list}
and({expr}, {expr}) Number bitwise AND
+api_info() Dict api metadata
append({lnum}, {string}) Number append {string} below line {lnum}
append({lnum}, {list}) Number append lines {list} below line {lnum}
argc() Number number of files in the argument list
@@ -1787,9 +1869,13 @@ argidx() Number current index in the argument list
arglistid([{winnr} [, {tabnr}]]) Number argument list id
argv({nr}) String {nr} entry of the argument list
argv() List the argument list
-assert_equal({exp}, {act} [, {msg}]) none assert {exp} equals {act}
-assert_exception({error} [, {msg}]) none assert {error} is in v:exception
+assert_equal({exp}, {act} [, {msg}]) none assert {exp} is equal to {act}
+assert_exception( {error} [, {msg}]) none assert {error} is in v:exception
+assert_fails( {cmd} [, {error}]) none assert {cmd} fails
assert_false({actual} [, {msg}]) none assert {actual} is false
+assert_match( {pat}, {text} [, {msg}]) none assert {pat} matches {text}
+assert_notequal( {exp}, {act} [, {msg}]) none assert {exp} is not equal {act}
+assert_notmatch( {pat}, {text} [, {msg}]) none assert {pat} not matches {text}
assert_true({actual} [, {msg}]) none assert {actual} is true
asin({expr}) Float arc sine of {expr}
atan({expr}) Float arc tangent of {expr}
@@ -1802,6 +1888,7 @@ buflisted({expr}) Number TRUE if buffer {expr} is listed
bufloaded({expr}) Number TRUE if buffer {expr} is loaded
bufname({expr}) String Name of the buffer {expr}
bufnr({expr} [, {create}]) Number Number of the buffer {expr}
+bufwinid({expr}) Number window ID of buffer {expr}
bufwinnr({expr}) Number window number of buffer {expr}
byte2line({byte}) Number line number at byte count {byte}
byteidx({expr}, {nr}) Number byte index of {nr}'th char in {expr}
@@ -1843,6 +1930,7 @@ escape({string}, {chars}) String escape {chars} in {string} with '\'
eval({string}) any evaluate {string} into its value
eventhandler() Number TRUE if inside an event handler
executable({expr}) Number 1 if executable {expr} exists
+execute({command}) String execute and capture output of {command}
exepath({expr}) String full path of the command {expr}
exists({expr}) Number TRUE if {expr} exists
extend({expr1}, {expr2} [, {expr3}])
@@ -1870,10 +1958,13 @@ foldlevel({lnum}) Number fold level at {lnum}
foldtext() String line displayed for closed fold
foldtextresult({lnum}) String text for closed fold at {lnum}
foreground() Number bring the Vim window to the foreground
-function({name}) Funcref reference to function {name}
+function({name} [, {arglist}] [, {dict}])
+ Funcref reference to function {name}
garbagecollect([{atexit}]) none free memory, breaking cyclic references
get({list}, {idx} [, {def}]) any get item {idx} from {list} or {def}
get({dict}, {key} [, {def}]) any get item {key} from {dict} or {def}
+get({func}, {what}) any get property of funcref/partial {func}
+getbufinfo( [{expr}]) List information about buffers
getbufline({expr}, {lnum} [, {end}])
List lines {lnum} to {end} of buffer {expr}
getbufvar({expr}, {varname} [, {def}])
@@ -1885,8 +1976,10 @@ getcmdline() String return the current command-line
getcmdpos() Number return cursor position in command-line
getcmdtype() String return current command-line type
getcmdwintype() String return current command-line window type
+getcompletion({pat}, {type} [, {filtered}])
+ List list of cmdline completion matches
getcurpos() List position of the cursor
-getcwd([{scope}]) String the current working directory
+getcwd([{winnr} [, {tabnr}]]) String the current working directory
getfontname([{name}]) String name of font being used
getfperm({fname}) String file permissions of file {fname}
getfsize({fname}) Number size in bytes of file {fname}
@@ -1902,10 +1995,12 @@ getqflist() List list of quickfix items
getreg([{regname} [, 1 [, {list}]]])
String or List contents of register
getregtype([{regname}]) String type of register
+gettabinfo( [{expr}]) List list of tab pages
gettabvar({nr}, {varname} [, {def}])
any variable {varname} in tab {nr} or {def}
gettabwinvar({tabnr}, {winnr}, {name} [, {def}])
any {name} in {winnr} in tab page {tabnr}
+getwininfo( [{winid}]) List list of windows
getwinposx() Number X coord in pixels of GUI Vim window
getwinposy() Number Y coord in pixels of GUI Vim window
getwinvar({nr}, {varname} [, {def}])
@@ -1917,10 +2012,11 @@ globpath({path}, {expr} [, {nosuf} [, {list} [, {alllinks}]]])
String do glob({expr}) for all dirs in {path}
has({feature}) Number TRUE if feature {feature} supported
has_key({dict}, {key}) Number TRUE if {dict} has entry {key}
-haslocaldir() Number TRUE if current window executed |:lcd|
+haslocaldir([{winnr} [, {tabnr}]])
+ Number TRUE if current window executed |:lcd|
hasmapto({what} [, {mode} [, {abbr}]])
Number TRUE if mapping to {what} exists
-histadd({history},{item}) String add an item to a history
+histadd({history}, {item}) String add an item to a history
histdel({history} [, {item}]) String remove an item from a history
histget({history} [, {index}]) String get the item {index} from a history
histnr({history}) Number highest index of a history
@@ -1986,6 +2082,8 @@ matchlist({expr}, {pat}[, {start}[, {count}]])
List match and submatches of {pat} in {expr}
matchstr({expr}, {pat}[, {start}[, {count}]])
String {count}'th match of {pat} in {expr}
+matchstrpos( {expr}, {pat}[, {start}[, {count}]])
+ List {count}'th match of {pat} in {expr}
max({list}) Number maximum value of items in {list}
min({list}) Number minimum value of items in {list}
mkdir({name} [, {path} [, {prot}]])
@@ -1995,6 +2093,7 @@ msgpackdump({list}) List dump a list of objects to msgpack
msgpackparse({list}) List parse msgpack to a list of objects
nextnonblank({lnum}) Number line nr of non-blank line >= {lnum}
nr2char({expr}[, {utf8}]) String single char with ASCII/UTF8 value {expr}
+nvim_...({args}...) any call nvim |api| functions
or({expr}, {expr}) Number bitwise OR
pathshorten({expr}) String shorten directory names in a path
pow({x}, {y}) Float {x} to the power of {y}
@@ -2018,7 +2117,7 @@ remote_peek({serverid} [, {retvar}])
remote_read({serverid}) String read reply string
remote_send({server}, {string} [, {idvar}])
String send key sequence
-remove({list}, {idx} [, {end}]) any remove items {idx}-{end} from {list}
+remove({list}, {idx} [, {end}]) any remove items {idx}-{end} from {list}
remove({dict}, {key}) any remove entry {key} from {dict}
rename({from}, {to}) Number rename (move) file from {from} to {to}
repeat({expr}, {count}) String repeat {expr} {count} times
@@ -2026,11 +2125,10 @@ resolve({filename}) String get filename a shortcut points to
reverse({list}) List reverse {list} in-place
round({expr}) Float round off {expr}
rpcnotify({channel}, {event}[, {args}...])
- Sends a |msgpack-rpc| notification to {channel}
+ Sends an |RPC| notification to {channel}
rpcrequest({channel}, {method}[, {args}...])
- Sends a |msgpack-rpc| request to {channel}
-rpcstart({prog}[, {argv}]) Spawns {prog} and opens a |msgpack-rpc| channel
-rpcstop({channel}) Closes a |msgpack-rpc| {channel}
+ Sends an |RPC| request to {channel}
+rpcstop({channel}) Closes an |RPC| {channel}
screenattr({row}, {col}) Number attribute at screen position
screenchar({row}, {col}) Number character at screen position
screencol() Number current cursor column
@@ -2084,14 +2182,17 @@ sqrt({expr}) Float square root of {expr}
str2float({expr}) Float convert String to Float
str2nr({expr} [, {base}]) Number convert String to Number
strchars({expr} [, {skipcc}]) Number character length of the String {expr}
+strcharpart({str}, {start}[, {len}])
+ String {len} characters of {str} at {start}
strdisplaywidth({expr} [, {col}]) Number display length of the String {expr}
strftime({format}[, {time}]) String time in specified format
+strgetchar({str}, {index}) Number get char {index} from {str}
stridx({haystack}, {needle}[, {start}])
Number index of {needle} in {haystack}
string({expr}) String String representation of {expr} value
strlen({expr}) Number length of the String {expr}
-strpart({src}, {start}[, {len}])
- String {len} characters of {src} at {start}
+strpart({str}, {start}[, {len}])
+ String {len} characters of {str} at {start}
strridx({haystack}, {needle} [, {start}])
Number last index of {needle} in {haystack}
strtrans({expr}) String translate string to make it printable
@@ -2108,15 +2209,18 @@ synconcealed({lnum}, {col}) List info about concealing
synstack({lnum}, {col}) List stack of syntax IDs at {lnum} and {col}
system({cmd} [, {input}]) String output of shell command/filter {cmd}
systemlist({cmd} [, {input}]) List output of shell command/filter {cmd}
-tabpagebuflist([{arg}]) List list of buffer numbers in tab page
+tabpagebuflist([{arg}]) List list of buffer numbers in tab page
tabpagenr([{arg}]) Number number of current or last tab page
tabpagewinnr({tabarg}[, {arg}])
Number number of current window in tab page
taglist({expr}) List list of tags matching {expr}
tagfiles() List tags files used
-tempname() String name for a temporary file
tan({expr}) Float tangent of {expr}
tanh({expr}) Float hyperbolic tangent of {expr}
+tempname() String name for a temporary file
+timer_start({time}, {callback} [, {options}])
+ Number create a timer
+timer_stop({timer}) none stop a timer
tolower({expr}) String the String {expr} switched to lowercase
toupper({expr}) String the String {expr} switched to uppercase
tr({src}, {fromstr}, {tostr}) String translate chars of {src} in {fromstr}
@@ -2131,6 +2235,11 @@ values({dict}) List values in {dict}
virtcol({expr}) Number screen column of cursor or mark
visualmode([expr]) String last visual mode used
wildmenumode() Number whether 'wildmenu' mode is active
+win_findbuf( {bufnr}) List find windows containing {bufnr}
+win_getid( [{win} [, {tab}]]) Number get window ID for {win} in {tab}
+win_gotoid( {expr}) Number go to window with ID {expr}
+win_id2tabwin( {expr}) List get tab window nr from window ID
+win_id2win( {expr}) Number get window nr from window ID
winbufnr({nr}) Number buffer number of window {nr}
wincol() Number window column of the cursor
winheight({nr}) Number height of window {nr}
@@ -2145,6 +2254,7 @@ writefile({list}, {fname} [, {flags}])
Number write list of lines to file {fname}
xor({expr}, {expr}) Number bitwise XOR
+
abs({expr}) *abs()*
Return the absolute value of {expr}. When {expr} evaluates to
a |Float| abs() returns a |Float|. When {expr} can be
@@ -2187,6 +2297,8 @@ and({expr}, {expr}) *and()*
Example: >
:let flag = and(bits, 0x80)
+api_info() *api_info()*
+ Returns Dictionary of |api-metadata|.
append({lnum}, {expr}) *append()*
When {expr} is a |List|: Append each item of the |List| as a
@@ -2208,7 +2320,7 @@ argidx() The result is the current index in the argument list. 0 is
the first file. argc() - 1 is the last one. See |arglist|.
*arglistid()*
-arglistid([{winnr}, [ {tabnr} ]])
+arglistid([{winnr} [, {tabnr}]])
Return the argument list ID. This is a number which
identifies the argument list being used. Zero is used for the
global argument list. See |arglist|.
@@ -2218,6 +2330,7 @@ arglistid([{winnr}, [ {tabnr} ]])
With {winnr} only use this window in the current tab page.
With {winnr} and {tabnr} use the window in the specified tab
page.
+ {winnr} can be the window number or the window ID.
*argv()*
argv([{nr}]) The result is the {nr}th file in the argument list of the
@@ -2260,6 +2373,11 @@ assert_exception({error} [, {msg}]) *assert_exception()*
call assert_exception('E492:')
endtry
+assert_fails({cmd} [, {error}]) *assert_fails()*
+ Run {cmd} and add an error message to |v:errors| if it does
+ NOT produce an error.
+ When {error} is given it must match |v:errmsg|.
+
assert_false({actual} [, {msg}]) *assert_false()*
When {actual} is not false an error message is added to
|v:errors|, like with |assert_equal()|.
@@ -2268,6 +2386,36 @@ assert_false({actual} [, {msg}]) *assert_false()*
When {msg} is omitted an error in the form "Expected False but
got {actual}" is produced.
+ *assert_match()*
+assert_match({pattern}, {actual} [, {msg}])
+ When {pattern} does not match {actual} an error message is
+ added to |v:errors|.
+
+ {pattern} is used as with |=~|: The matching is always done
+ like 'magic' was set and 'cpoptions' is empty, no matter what
+ the actual value of 'magic' or 'cpoptions' is.
+
+ {actual} is used as a string, automatic conversion applies.
+ Use "^" and "$" to match with the start and end of the text.
+ Use both to match the whole text.
+
+ When {msg} is omitted an error in the form "Pattern {pattern}
+ does not match {actual}" is produced.
+ Example: >
+ 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' ~
+
+ *assert_notequal()*
+assert_notequal({expected}, {actual} [, {msg}])
+ The opposite of `assert_equal()`: add an error message to
+ |v:errors| when {expected} and {actual} are equal.
+
+ *assert_notmatch()*
+assert_notmatch({pattern}, {actual} [, {msg}])
+ The opposite of `assert_match()`: add an error message to
+ |v:errors| when {pattern} matches {actual}.
+
assert_true({actual} [, {msg}]) *assert_true()*
When {actual} is not true an error message is added to
|v:errors|, like with |assert_equal()|.
@@ -2354,8 +2502,6 @@ bufexists({expr}) *bufexists()*
for MS-Windows 8.3 names in the form "c:\DOCUME~1"
Use "bufexists(0)" to test for the existence of an alternate
file name.
- *buffer_exists()*
- Obsolete name: buffer_exists().
buflisted({expr}) *buflisted()*
The result is a Number, which is non-zero if a buffer called
@@ -2394,8 +2540,6 @@ bufname({expr}) *bufname()*
bufname(3) name of buffer 3
bufname("%") name of current buffer
bufname("file2") name of buffer where "file2" matches.
-< *buffer_name()*
- Obsolete name: buffer_name().
*bufnr()*
bufnr({expr} [, {create}])
@@ -2411,10 +2555,16 @@ bufnr({expr} [, {create}])
of existing buffers. Note that not all buffers with a smaller
number necessarily exist, because ":bwipeout" may have removed
them. Use bufexists() to test for the existence of a buffer.
- *buffer_number()*
- Obsolete name: buffer_number().
- *last_buffer_nr()*
- Obsolete name for bufnr("$"): last_buffer_nr().
+
+bufwinid({expr}) *bufwinid()*
+ The result is a Number, which is the window ID of the first
+ window associated with buffer {expr}. For the use of {expr},
+ see |bufname()| above. If buffer {expr} doesn't exist or
+ there is no such window, -1 is returned. Example: >
+
+ echo "A window containing buffer 1 is " . (bufwinid(1))
+<
+ Only deals with the current tab page.
bufwinnr({expr}) *bufwinnr()*
The result is a Number, which is the number of the first
@@ -2452,7 +2602,9 @@ byteidx({expr}, {nr}) *byteidx()*
same: >
let s = strpart(str, byteidx(str, 3))
echo strpart(s, 0, byteidx(s, 1))
-< If there are less than {nr} characters -1 is returned.
+< Also see |strgetchar()| and |strcharpart()|.
+
+ If there are less than {nr} characters -1 is returned.
If there are exactly {nr} characters the length of the string
in bytes is returned.
@@ -2466,8 +2618,6 @@ byteidxcomp({expr}, {nr}) *byteidxcomp()*
< The first and third echo result in 3 ('e' plus composing
character is 3 bytes), the second echo results in 1 ('e' is
one byte).
- Only works different from byteidx() when 'encoding' is set to
- a Unicode encoding.
call({func}, {arglist} [, {dict}]) *call()* *E699*
Call function {func} with the items in |List| {arglist} as
@@ -2502,11 +2652,11 @@ char2nr({expr}[, {utf8}]) *char2nr()*
Return number value of the first char in {expr}. Examples: >
char2nr(" ") returns 32
char2nr("ABC") returns 65
-< When {utf8} is omitted or zero, the current 'encoding' is used.
- Example for "utf-8": >
char2nr("á") returns 225
char2nr("á"[0]) returns 195
-< With {utf8} set to 1, always treat as utf-8 characters.
+< Non-ASCII characters are always treated as UTF-8 characters.
+ {utf8} has no effect, and exists only for
+ backwards-compatibility.
A combining character is a separate character.
|nr2char()| does the opposite.
@@ -2745,6 +2895,7 @@ cursor({list})
When there is one argument {list} this is used as a |List|
with two, three or four item:
+ [{lnum}, {col}]
[{lnum}, {col}, {off}]
[{lnum}, {col}, {off}, {curswant}]
This is like the return value of |getpos()| or |getcurpos()|,
@@ -2811,6 +2962,13 @@ dictwatcheradd({dict}, {pattern}, {callback}) *dictwatcheradd()*
After this is called, every change on {dict} and on keys
matching {pattern} will result in {callback} being invoked.
+ For example, to watch all global variables: >
+ silent! call dictwatcherdel(g:, '*', 'OnDictChanged')
+ function! OnDictChanged(d,k,z)
+ echomsg string(a:k) string(a:z)
+ endfunction
+ call dictwatcheradd(g:, '*', 'OnDictChanged')
+<
For now {pattern} only accepts very simple patterns that can
contain a '*' at the end of the string, in which case it will
match every key that begins with the substring before the '*'.
@@ -2821,7 +2979,7 @@ dictwatcheradd({dict}, {pattern}, {callback}) *dictwatcheradd()*
- The dictionary being watched.
- The key which changed.
- - A dictionary containg the new and old values for the key.
+ - A dictionary containing the new and old values for the key.
The type of change can be determined by examining the keys
present on the third argument:
@@ -2920,6 +3078,31 @@ executable({expr}) *executable()*
0 does not exist
-1 not implemented on this system
+execute({command} [, {silent}]) *execute()*
+ Execute {command} and capture its output.
+ If {command} is a |String|, returns {command} output.
+ If {command} is a |List|, returns concatenated outputs.
+ Examples: >
+ echo execute('echon "foo"')
+< foo >
+ echo execute(['echon "foo"', 'echon "bar"'])
+< foobar
+
+ The optional {silent} argument can have these values:
+ "" no `:silent` used
+ "silent" `:silent` used
+ "silent!" `:silent!` used
+ The default is 'silent'. Note that with "silent!", unlike
+ `:redir`, error messages are dropped.
+
+ To get a list of lines use |split()| on the result: >
+ split(execute('args'), "\n")
+
+< This function is not available in the |sandbox|.
+ Note: If nested, an outer execute() will not observe output of
+ the inner calls.
+ Note: Text attributes (highlights) are not captured.
+
exepath({expr}) *exepath()*
If {expr} is an executable and is either an absolute path, a
relative path or found in $PATH, return the full path.
@@ -3162,6 +3345,18 @@ feedkeys({string} [, {mode}]) *feedkeys()*
if coming from a mapping. This matters for undo,
opening folds, etc.
'i' Insert the string instead of appending (see above).
+ 'x' Execute commands until typeahead is empty. This is
+ similar to using ":normal!". You can call feedkeys()
+ several times without 'x' and then one time with 'x'
+ (possibly with an empty {string}) to execute all the
+ typeahead. Note that when Vim ends in Insert mode it
+ will behave as if <Esc> is typed, to avoid getting
+ stuck, waiting for a character to be typed before the
+ script continues.
+ '!' When used with 'x' will not end Insert mode. Can be
+ used in a test when a timer is set to exit Insert mode
+ a little later. Useful for testing CursorHoldI.
+
Return value is always 0.
filereadable({file}) *filereadable()*
@@ -3171,8 +3366,6 @@ filereadable({file}) *filereadable()*
expression, which is used as a String.
If you don't care about the file being readable you can use
|glob()|.
- *file_readable()*
- Obsolete name: file_readable().
filewritable({file}) *filewritable()*
@@ -3359,10 +3552,46 @@ foreground() Move the Vim window to the foreground. Useful when sent from
{only in the Win32 GUI and console version}
-function({name}) *function()* *E700*
+ *function()* *E700* *E922* *E923*
+function({name} [, {arglist}] [, {dict}])
Return a |Funcref| variable that refers to function {name}.
{name} can be a user defined function or an internal function.
+ When {arglist} or {dict} is present this creates a partial.
+ That mans the argument list and/or the dictionary is stored in
+ the Funcref and will be used when the Funcref is called.
+
+ The arguments are passed to the function in front of other
+ arguments. Example: >
+ func Callback(arg1, arg2, name)
+ ...
+ let Func = function('Callback', ['one', 'two'])
+ ...
+ call Func('name')
+< Invokes the function as with: >
+ call Callback('one', 'two', 'name')
+
+< The Dictionary is only useful when calling a "dict" function.
+ In that case the {dict} is passed in as "self". Example: >
+ function Callback() dict
+ echo "called for " . self.name
+ endfunction
+ ...
+ let context = {"name": "example"}
+ let Func = function('Callback', context)
+ ...
+ call Func() " will echo: called for example
+
+< The argument list and the Dictionary can be combined: >
+ function Callback(arg1, count) dict
+ ...
+ let context = {"name": "example"}
+ let Func = function('Callback', ['one'], context)
+ ...
+ call Func(500)
+< Invokes the function as with: >
+ call context.Callback('one', 500)
+
garbagecollect([{atexit}]) *garbagecollect()*
Cleanup unused |Lists| and |Dictionaries| that have circular
@@ -3386,7 +3615,68 @@ get({dict}, {key} [, {default}])
Get item with key {key} from |Dictionary| {dict}. When this
item is not available return {default}. Return zero when
{default} is omitted.
+get({func}, {what})
+ 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
+
+ *getbufinfo()*
+getbufinfo([{expr}])
+getbufinfo([{dict}])
+ Get information about buffers as a List of Dictionaries.
+
+ Without an argument information about all the buffers is
+ returned.
+
+ When the argument is a Dictionary only the buffers matching
+ the specified criteria are returned. The following keys can
+ be specified in {dict}:
+ buflisted include only listed buffers.
+ bufloaded include only loaded buffers.
+
+ Otherwise, {expr} specifies a particular buffer to return
+ information for. For the use of {expr}, see |bufname()|
+ above. If the buffer is found the returned List has one item.
+ Otherwise the result is an empty list.
+
+ Each returned List item is a dictionary with the following
+ entries:
+ bufnr buffer number.
+ changed TRUE if the buffer is modified.
+ changedtick number of changes made to the buffer.
+ hidden TRUE if the buffer is hidden.
+ listed TRUE if the buffer is listed.
+ lnum current line number in buffer.
+ loaded TRUE if the buffer is loaded.
+ name full path to the file in the buffer.
+ signs list of signs placed in the buffer.
+ Each list item is a dictionary with
+ the following fields:
+ id sign identifier
+ lnum line number
+ name sign name
+ variables a reference to the dictionary with
+ buffer-local variables.
+ windows list of |window-ID|s that display this
+ buffer
+ Examples: >
+ for buf in getbufinfo()
+ echo buf.name
+ endfor
+ for buf in getbufinfo({'buflisted':1})
+ if buf.changed
+ ....
+ endif
+ endfor
+<
+ To get buffer-local options use: >
+ getbufvar({bufnr}, '&')
+
+<
*getbufline()*
getbufline({expr}, {lnum} [, {end}])
Return a |List| with the lines starting from {lnum} to {end}
@@ -3418,6 +3708,10 @@ getbufvar({expr}, {varname} [, {def}]) *getbufvar()*
must be used.
When {varname} is empty returns a dictionary with all the
buffer-local variables.
+ When {varname} is equal to "&" returns a dictionary with all
+ the buffer-local options.
+ Otherwise, when {varname} starts with "&" returns the value of
+ a buffer-local option.
This also works for a global or buffer-local option, but it
doesn't work for a global variable, window-local variable or
window-local option.
@@ -3458,8 +3752,8 @@ getchar([expr]) *getchar()*
When the user clicks a mouse button, the mouse event will be
returned. The position can then be found in |v:mouse_col|,
- |v:mouse_lnum| and |v:mouse_win|. This example positions the
- mouse as it would normally happen: >
+ |v:mouse_lnum|, |v:mouse_winid| and |v:mouse_win|. This
+ example positions the mouse as it would normally happen: >
let c = getchar()
if c == "\<LeftMouse>" && v:mouse_win > 0
exe v:mouse_win . "wincmd w"
@@ -3570,10 +3864,57 @@ getcmdwintype() *getcmdwintype()*
values are the same as |getcmdtype()|. Returns an empty string
when not in the command-line window.
+getcompletion({pat}, {type} [, {filtered}]) *getcompletion()*
+ Return a list of command-line completion matches. {type}
+ specifies what for. The following completion types are
+ supported:
+
+ augroup autocmd groups
+ buffer buffer names
+ behave :behave suboptions
+ color color schemes
+ command Ex command (and arguments)
+ compiler compilers
+ cscope |:cscope| suboptions
+ dir directory names
+ environment environment variable names
+ event autocommand events
+ expression Vim expression
+ file file and directory names
+ file_in_path file and directory names in |'path'|
+ filetype filetype names |'filetype'|
+ function function name
+ help help subjects
+ highlight highlight groups
+ history :history suboptions
+ locale locale names (as output of locale -a)
+ mapping mapping name
+ menu menus
+ option options
+ shellcmd Shell command
+ sign |:sign| suboptions
+ syntax syntax file names |'syntax'|
+ syntime |:syntime| suboptions
+ tag tags
+ tag_listfiles tags, file names
+ user user names
+ var user variables
+
+ If {pat} is an empty string, then all the matches are returned.
+ Otherwise only items matching {pat} are returned. See
+ |wildcards| for the use of special characters in {pat}.
+
+ If the optional {filtered} flag is set to 1, then 'wildignore'
+ is applied to filter the results. Otherwise all the matches
+ are returned. The 'wildignorecase' option always applies.
+
+ If there are no matches, an empty list is returned. An
+ invalid value for {type} produces an error.
+
*getcurpos()*
getcurpos() Get the position of the cursor. This is like getpos('.'), but
includes an extra item in the list:
- [bufnum, lnum, col, off, curswant]
+ [bufnum, lnum, col, off, curswant] ~
The "curswant" number is the preferred column when moving the
cursor vertically.
This can be used to save and restore the cursor position: >
@@ -3581,17 +3922,18 @@ getcurpos() Get the position of the cursor. This is like getpos('.'), but
MoveTheCursorAround
call setpos('.', save_cursor)
<
-getcwd([{window}[, {tab}]]) *getcwd()*
+getcwd([{winnr}[, {tabnr}]]) *getcwd()*
With no arguments the result is a String, which is the name of
- the current effective working directory. With {window} or
- {tab} the working directory of that scope is returned.
+ the current effective working directory. With {winnr} or
+ {tabnr} the working directory of that scope is returned.
Tabs and windows are identified by their respective numbers,
0 means current tab or window. Missing argument implies 0.
Thus the following are equivalent: >
getcwd()
getcwd(0)
getcwd(0, 0)
-< If {window} is -1 it is ignored, only the tab is resolved.
+< If {winnr} is -1 it is ignored, only the tab is resolved.
+ {winnr} can be the window number or the window ID.
getfsize({fname}) *getfsize()*
@@ -3656,7 +3998,8 @@ getftype({fname}) *getftype()*
getftype("/home")
< Note that a type such as "link" will only be returned on
systems that support it. On some systems only "dir" and
- "file" are returned.
+ "file" are returned. On MS-Windows a symbolic link to a
+ directory returns "dir" instead of "link".
*getline()*
getline({lnum} [, {end}])
@@ -3685,7 +4028,9 @@ getline({lnum} [, {end}])
getloclist({nr}) *getloclist()*
Returns a list with all the entries in the location list for
- window {nr}. When {nr} is zero the current window is used.
+ window {nr}. {nr} can be the window number or the window ID.
+ When {nr} is zero the current window is used.
+
For a location list window, the displayed location list is
returned. For an invalid window number {nr}, an empty list is
returned. Otherwise, same as |getqflist()|.
@@ -3770,16 +4115,21 @@ getreg([{regname} [, 1 [, {list}]]]) *getreg()*
The result is a String, which is the contents of register
{regname}. Example: >
:let cliptext = getreg('*')
-< getreg('=') returns the last evaluated value of the expression
+< When {regname} was not set the result is a empty string.
+
+ getreg('=') returns the last evaluated value of the expression
register. (For use in maps.)
getreg('=', 1) returns the expression itself, so that it can
be restored with |setreg()|. For other registers the extra
argument is ignored, thus you can always give it.
- If {list} is present and non-zero result type is changed to
- |List|. Each list item is one text line. Use it if you care
+
+ If {list} is present and non-zero, the result type is changed
+ to |List|. Each list item is one text line. Use it if you care
about zero bytes possibly present inside register: without
third argument both NLs and zero bytes are represented as NLs
(see |NL-used-for-Nul|).
+ When the register was not set an empty list is returned.
+
If {regname} is not specified, |v:register| is used.
@@ -3793,6 +4143,19 @@ getregtype([{regname}]) *getregtype()*
<CTRL-V> is one character with value 0x16.
If {regname} is not specified, |v:register| is used.
+gettabinfo([{arg}]) *gettabinfo()*
+ If {arg} is not specified, then information about all the tab
+ pages is returned as a List. Each List item is a Dictionary.
+ Otherwise, {arg} specifies the tab page number and information
+ about that one is returned. If the tab page does not exist an
+ empty List is returned.
+
+ Each List item is a Dictionary with the following entries:
+ nr tab page number.
+ variables a reference to the dictionary with
+ tabpage-local variables
+ windows List of window IDs in the tag page.
+
gettabvar({tabnr}, {varname} [, {def}]) *gettabvar()*
Get the value of a tab-local variable {varname} in tab page
{tabnr}. |t:var|
@@ -3806,13 +4169,16 @@ gettabvar({tabnr}, {varname} [, {def}]) *gettabvar()*
gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()*
Get the value of window-local variable {varname} in window
{winnr} in tab page {tabnr}.
- When {varname} starts with "&" get the value of a window-local
- option.
When {varname} is empty a dictionary with all window-local
variables is returned.
+ When {varname} is equal to "&" get the values of all
+ window-local options in a Dictionary.
+ Otherwise, when {varname} starts with "&" get the value of a
+ window-local option.
Note that {varname} must be the name without "w:".
Tabs are numbered starting with one. For the current tabpage
use |getwinvar()|.
+ {winnr} can be the window number or the window ID.
When {winnr} is zero the current window is used.
This also works for a global option, buffer-local option and
window-local option, but it doesn't work for a global variable
@@ -3833,6 +4199,31 @@ 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.
+getwininfo([{winid}]) *getwininfo()*
+ Returns information about windows as a List with Dictionaries.
+
+ If {winid} is given Information about the window with that ID
+ is returned. If the window does not exist the result is an
+ empty list.
+
+ Without an information about all the windows in all the tab
+ pages is returned.
+
+ Each List item is a Dictionary with the following entries:
+ bufnum number of buffer in the window
+ height window height
+ loclist 1 if showing a location list
+ nr window number
+ quickfix 1 if quickfix or location list window
+ tpnr tab page number
+ variables a reference to the dictionary with
+ window-local variables
+ width window width
+ winid window ID
+
+ To obtain all window-local variables use: >
+ gettabwinvar({tabnr}, {winnr}, '&')
+
getwinvar({winnr}, {varname} [, {def}]) *getwinvar()*
Like |gettabwinvar()| for the current tabpage.
Examples: >
@@ -3929,7 +4320,7 @@ has_key({dict}, {key}) *has_key()*
The result is a Number, which is 1 if |Dictionary| {dict} has
an entry with key {key}. Zero otherwise.
-haslocaldir([{window}[, {tab}]]) *haslocaldir()*
+haslocaldir([{winnr}[, {tabnr}]]) *haslocaldir()*
The result is a Number, which is 1 when the specified tabpage
or window has a local path set via |:lcd| or |:tcd|, and
0 otherwise.
@@ -3940,7 +4331,8 @@ haslocaldir([{window}[, {tab}]]) *haslocaldir()*
haslocaldir()
haslocaldir(0)
haslocaldir(0, 0)
-< If {window} is -1 it is ignored, only the tab is resolved.
+< {winnr} can be the window number or the window ID.
+ If {winnr} is -1 it is ignored, only the tab is resolved.
hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()*
The result is a Number, which is 1 if there is a mapping that
@@ -4051,8 +4443,6 @@ hlexists({name}) *hlexists()*
defined in some way. Not necessarily when highlighting has
been defined for it, it may also have been used for a syntax
item.
- *highlight_exists()*
- Obsolete name: highlight_exists().
*hlID()*
hlID({name}) The result is a Number, which is the ID of the highlight group
@@ -4062,8 +4452,6 @@ hlID({name}) The result is a Number, which is the ID of the highlight group
group. For example, to get the background color of the
"Comment" group: >
:echo synIDattr(synIDtrans(hlID("Comment")), "bg")
-< *highlightID()*
- Obsolete name: highlightID().
hostname() *hostname()*
The result is a String, which is the name of the machine on
@@ -4081,11 +4469,7 @@ iconv({expr}, {from}, {to}) *iconv()*
Most conversions require Vim to be compiled with the |+iconv|
feature. Otherwise only UTF-8 to latin1 conversion and back
can be done.
- This can be used to display messages with special characters,
- no matter what 'encoding' is set to. Write the message in
- UTF-8 and use: >
- echo iconv(utf8_str, "utf-8", &enc)
-< Note that Vim uses UTF-8 for all Unicode encodings, conversion
+ Note that Vim uses UTF-8 for all Unicode encodings, conversion
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.
{only available when compiled with the |+multi_byte| feature}
@@ -4259,8 +4643,11 @@ items({dict}) *items()*
order.
jobclose({job}[, {stream}]) {Nvim} *jobclose()*
- Close {job}'s {stream}, which can be one "stdin", "stdout" or
- "stderr". If {stream} is omitted, all streams are closed.
+ Close {job}'s {stream}, which can be one of "stdin", "stdout",
+ "stderr" or "rpc" (closes the rpc channel for a job started
+ with the "rpc" option.) If {stream} is omitted, all streams
+ are closed. If the job is a pty job, this will then close the
+ pty master, sending SIGHUP to the job process.
jobpid({job}) {Nvim} *jobpid()*
Return the pid (process id) of {job}.
@@ -4282,42 +4669,55 @@ jobsend({job}, {data}) {Nvim} *jobsend()*
:call jobsend(j, ["abc", "123\n456", ""])
< will send "abc<NL>123<NUL>456<NL>".
+ If the job was started with the rpc option this function
+ cannot be used, instead use |rpcnotify()| and |rpcrequest()|
+ to communicate with the job.
+
jobstart({cmd}[, {opts}]) {Nvim} *jobstart()*
- Spawns {cmd} as a job. If {cmd} is a |List|, it will be run
- directly. If {cmd} is a |string|, it will be roughly
- equivalent to >
- :call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
-< NOTE: read |shell-unquoting| before constructing any lists
- with 'shell' or 'shellcmdflag' options. The above call is
- only written to show the idea, one needs to perform unquoting
- and do split taking quotes into account.
- If passed, {opts} must be a dictionary with any of the
- following keys:
- - on_stdout: stdout event handler
- - on_stderr: stderr event handler
- - on_exit: exit event handler
- - pty: If set, the job will be connected to a new pseudo
- terminal, and the job streams are connected to the master
- file descriptor.
- - width: Width of the terminal screen(only if pty is set)
- - height: Height of the terminal screen(only if pty is set)
- - TERM: $TERM environment variable(only if pty is set)
- - detach: Detach the job process from the nvim process. The
- process won't get killed when nvim exists. If the process
- dies before nvim exits, on_exit will still be invoked.
- This option is only allowed for non-pty jobs.
- Either funcrefs or function names can be passed as event
- handlers. The {opts} object is also used as the "self"
- argument for the callback, so the caller may pass arbitrary
- data by setting other key.(see |Dictionary-function| for more
- information).
+ Spawns {cmd} as a job. If {cmd} is a |List| it is run
+ directly. If {cmd} is a |String| it is processed like this: >
+ :call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
+< NOTE: This only shows the idea; see |shell-unquoting| before
+ constructing lists with 'shell' or 'shellcmdflag'.
+
+ NOTE: On Windows if {cmd} is a List, cmd[0] must be a valid
+ executable (.exe, .com). If the executable is in $PATH it can
+ be called by name, with or without an extension: >
+ :call jobstart(['ping', 'neovim.io'])
+< If it is a path (not a name), it must include the extension: >
+ :call jobstart(['System32\ping.exe', 'neovim.io'])
+<
+ {opts} is a dictionary with these keys:
+ on_stdout: stdout event handler (function name or |Funcref|)
+ on_stderr: stderr event handler (function name or |Funcref|)
+ on_exit : exit event handler (function name or |Funcref|)
+ cwd : Working directory of the job; defaults to
+ |current-directory|.
+ rpc : If set, |msgpack-rpc| will be used to communicate
+ with the job over stdin and stdout. "on_stdout" is
+ then ignored, but "on_stderr" can still be used.
+ pty : If set, the job will be connected to a new pseudo
+ terminal, and the job streams are connected to
+ the master file descriptor. "on_stderr" is ignored
+ as all output will be received on stdout.
+
+ width : (pty only) Width of the terminal screen
+ height : (pty only) Height of the terminal screen
+ TERM : (pty only) $TERM environment variable
+ detach : (non-pty only) Detach the job process from the
+ nvim process. The process will not get killed
+ when nvim exits. If the process dies before
+ nvim exits, on_exit will still be invoked.
+
+ {opts} is passed as |self| to the callback; the caller may
+ pass arbitrary data by setting other keys.
Returns:
- - The job ID on success, which is used by |jobsend()| and
- |jobstop()|
- - 0 when the job table is full or on invalid arguments
- - -1 when {cmd}[0] is not executable. Will never fail if
- {cmd} is a string unless 'shell' is not executable.
- See |job-control| for more information.
+ - The job ID on success, which is used by |jobsend()| (or
+ |rpcnotify()| and |rpcrequest()| if "rpc" option was used)
+ and |jobstop()|
+ - 0 on invalid arguments or if the job table is full
+ - -1 if {cmd}[0] is not executable.
+ See |job-control| and |msgpack-rpc| for more information.
jobstop({job}) {Nvim} *jobstop()*
Stop a job created with |jobstart()| by sending a `SIGTERM`
@@ -4359,9 +4759,7 @@ join({list} [, {sep}]) *join()*
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
- Vim value. When 'encoding' is not UTF-8 string is converted
- from UTF-8 to 'encoding', failing conversion fails
- json_decode(). In the following cases it will output
+ Vim value. In the following cases it will output
|msgpack-special-dict|:
1. Dictionary contains duplicate key.
2. Dictionary contains empty key.
@@ -4369,33 +4767,22 @@ json_decode({expr}) *json_decode()*
dictionary and for string will be emitted in case string
with NUL byte was a dictionary key.
- Note: function treats its input as UTF-8 always regardless of
- 'encoding' value. This is needed because JSON source is
- supposed to be external (e.g. |readfile()|) and JSON standard
- allows only a few encodings, of which UTF-8 is recommended and
- the only one required to be supported. Non-UTF-8 characters
- are an error.
+ Note: function treats its input as UTF-8 always. The JSON
+ standard allows only a few encodings, of which UTF-8 is
+ recommended and the only one required to be supported.
+ Non-UTF-8 characters are an error.
json_encode({expr}) *json_encode()*
Convert {expr} into a JSON string. Accepts
- |msgpack-special-dict| as the input. Converts from 'encoding'
- to UTF-8 when encoding strings. Will not convert |Funcref|s,
+ |msgpack-special-dict| as the input. Will not convert |Funcref|s,
mappings with non-string keys (can be created as
|msgpack-special-dict|), values with self-referencing
containers, strings which contain non-UTF-8 characters,
pseudo-UTF-8 strings which contain codepoints reserved for
surrogate pairs (such strings are not valid UTF-8 strings).
- When converting 'encoding' is taken into account, if it is not
- "utf-8", then conversion is performed before encoding strings.
Non-printable characters are converted into "\u1234" escapes
or special escapes like "\t", other are dumped as-is.
- Note: all characters above U+0079 are considered non-printable
- when 'encoding' is not UTF-8. This function always outputs
- UTF-8 strings as required by the standard thus when 'encoding'
- is not unicode resulting string will look incorrect if
- "\u1234" notation is not used.
-
keys({dict}) *keys()*
Return a |List| with all the keys of {dict}. The |List| is in
arbitrary order.
@@ -4497,9 +4884,9 @@ 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
the 'fileformat' option for the current buffer. The first
- line returns 1. 'encoding' matters, 'fileencoding' is ignored.
- This can also be used to get the byte count for the line just
- below the last line: >
+ line returns 1. UTF-8 encoding is used, 'fileencoding' is
+ ignored. This can also be used to get the byte count for the
+ line just below the last line: >
line2byte(line("$") + 1)
< This is the buffer size plus one. If 'fileencoding' is empty
it is the file size plus one.
@@ -4737,8 +5124,8 @@ matchadd({group}, {pattern}[, {priority}[, {id} [, {dict}]]])
respectively. If the {id} argument is not specified or -1,
|matchadd()| automatically chooses a free ID.
- The optional {dict} argmument allows for further custom
- values. Currently this is used to specify a match specifc
+ The optional {dict} argument allows for further custom
+ values. Currently this is used to specify a match specific
conceal character that will be shown for |hl-Conceal|
highlighted matches. The dict can have the following members:
@@ -4854,6 +5241,24 @@ 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.
+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: >
+ :echo matchstrpos("testing", "ing")
+< results in ["ing", 4, 7].
+ When there is no match ["", -1, -1] is returned.
+ The {start}, if given, has the same meaning as for |match()|. >
+ :echo matchstrpos("testing", "ing", 2)
+< results in ["ing", 4, 7]. >
+ :echo matchstrpos("testing", "ing", 5)
+< result is ["", -1, -1].
+ When {expr} is a |List| then the matching item, the index
+ of first item where {pat} matches, the start position and the
+ end position of the match are returned. >
+ :echo matchstrpos([1, '__x'], '\a')
+< result is ["x", 1, 2, 3].
+ The type isn't changed, it's not necessarily a String.
+
*max()*
max({list}) Return the maximum value of all items in {list}.
If {list} is not a list or one of the items in {list} cannot
@@ -4923,7 +5328,7 @@ msgpackdump({list}) {Nvim} *msgpackdump()*
(dictionary with zero items is represented by 0x80 byte in
messagepack).
- Limitations: *E951* *E952* *E953*
+ Limitations: *E5004* *E5005*
1. |Funcref|s cannot be dumped.
2. Containers that reference themselves cannot be dumped.
3. Dictionary keys are always dumped as STR strings.
@@ -5018,15 +5423,26 @@ nr2char({expr}[, {utf8}]) *nr2char()*
value {expr}. Examples: >
nr2char(64) returns "@"
nr2char(32) returns " "
-< When {utf8} is omitted or zero, the current 'encoding' is used.
- Example for "utf-8": >
+< Example for "utf-8": >
nr2char(300) returns I with bow character
-< With {utf8} set to 1, always return utf-8 characters.
+< UTF-8 encoding is always used, {utf8} option has no effect,
+ and exists only for backwards-compatibility.
Note that a NUL character in the file is specified with
nr2char(10), because NULs are represented with newline
characters. nr2char(0) is a real NUL and terminates the
string, thus results in an empty string.
+nvim_...({...}) *nvim_...()* *eval-api*
+ Call nvim |api| functions. The type checking of arguments will
+ be stricter than for most other builtins. For instance,
+ if Integer is expected, a |Number| must be passed in, a
+ |String| will not be autoconverted.
+ Buffer numbers, as returned by |bufnr()| could be used as
+ first argument to nvim_buf_... functions. All functions
+ expecting an object (buffer, window or tabpage) can
+ also take the numerical value 0 to indicate the current
+ (focused) object.
+
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.
@@ -5180,6 +5596,16 @@ printf({fmt}, {expr1} ...) *printf()*
numeric field; if the result of a conversion is wider
than the field width, the field is expanded to contain
the conversion result.
+ The 'h' modifier indicates the argument is 16 bits.
+ The 'l' modifier indicates the argument is 32 bits.
+ The 'L' modifier indicates the argument is 64 bits.
+ Generally, these modifiers are not useful. They are
+ ignored when type is known from the argument.
+
+ i alias for d
+ D alias for ld
+ U alias for lu
+ O alias for lo
*printf-c*
c The Number argument is converted to a byte, and the
@@ -5196,7 +5622,7 @@ printf({fmt}, {expr1} ...) *printf()*
feature works just like 's'.
*printf-f* *E807*
- f The Float argument is converted into a string of the
+ f F The Float argument is converted into a string of the
form 123.456. The precision specifies the number of
digits after the decimal point. When the precision is
zero the decimal point is omitted. When the precision
@@ -5246,13 +5672,12 @@ pumvisible() *pumvisible()*
This can be used to avoid some things that would remove the
popup menu.
- *E860*
py3eval({expr}) *py3eval()*
Evaluate Python expression {expr} and return its result
converted to Vim data structures.
Numbers and strings are returned as they are (strings are
copied though, Unicode strings are additionally converted to
- 'encoding').
+ UTF-8).
Lists are represented as Vim |List| type.
Dictionaries are represented as Vim |Dictionary| type with
keys converted to strings.
@@ -5302,8 +5727,7 @@ readfile({fname} [, {binary} [, {max}]])
Otherwise:
- CR characters that appear before a NL are removed.
- Whether the last line ends in a NL or not does not matter.
- - When 'encoding' is Unicode any UTF-8 byte order mark is
- removed from the text.
+ - Any UTF-8 byte order mark is removed from the text.
When {max} is given this specifies the maximum number of lines
to be read. Useful if you only want to check the first ten
lines of a file: >
@@ -5325,14 +5749,20 @@ reltime([{start} [, {end}]]) *reltime()*
the item depends on the system. It can be passed to
|reltimestr()| to convert it to a string or |reltimefloat()|
to convert to a float.
- Without an argument it returns the current time.
- With one argument is returns the time passed since the time
+
+ Without an argument it returns the current "relative time", an
+ implementation-defined value meaningful only when used as an
+ argument to |reltime()|, |reltimestr()| and |reltimefloat()|.
+
+ With one argument it returns the time passed since the time
specified in the argument.
With two arguments it returns the time passed between {start}
and {end}.
The {start} and {end} arguments must be values returned by
reltime().
+ Note: |localtime()| returns the current (non-relative) time.
+
reltimefloat({time}) *reltimefloat()*
Return a Float that represents the time value of {time}.
Unit of time is seconds.
@@ -5504,31 +5934,31 @@ round({expr}) *round()*
< -5.0
rpcnotify({channel}, {event}[, {args}...]) {Nvim} *rpcnotify()*
- Sends {event} to {channel} via |msgpack-rpc| and returns
- immediately. If {channel} is 0, the event is broadcast to all
- channels. Example: >
+ Sends {event} to {channel} via |RPC| and returns immediately.
+ If {channel} is 0, the event is broadcast to all channels.
+ Example: >
:au VimLeave call rpcnotify(0, "leaving")
rpcrequest({channel}, {method}[, {args}...]) {Nvim} *rpcrequest()*
Sends a request to {channel} to invoke {method} via
- |msgpack-rpc| and blocks until a response is received.
+ |RPC| and blocks until a response is received.
Example: >
:let result = rpcrequest(rpc_chan, "func", 1, 2, 3)
rpcstart({prog}[, {argv}]) {Nvim} *rpcstart()*
- Spawns {prog} as a job (optionally passing the list {argv}),
- and opens a |msgpack-rpc| channel with the spawned process's
- stdin/stdout. It returns:
- - The channel id on success, which is used by |rpcrequest()|,
- |rpcnotify()| and |rpcstop()|
- - 0 on failure.
- Example: >
- :let rpc_chan = rpcstart('prog', ['arg1', 'arg2'])
+ Deprecated. Replace >
+ :let id = rpcstart('prog', ['arg1', 'arg2'])
+< with >
+ :let id = jobstart(['prog', 'arg1', 'arg2'], {'rpc': v:true})
rpcstop({channel}) {Nvim} *rpcstop()*
- Closes a |msgpack-rpc| {channel}, possibly created via
- |rpcstart()|. Also closes channels created by connections to
- |$NVIM_LISTEN_ADDRESS|.
+ Closes an |RPC| {channel}. If the channel is a job
+ started with |jobstart()| the job is killed.
+ It is better to use |jobstop()| in this case, or use
+ |jobclose|(id, "rpc") to only close the channel without
+ killing the job.
+ Closes the socket connection if the channel was opened by
+ connecting to |v:servername|.
screenattr(row, col) *screenattr()*
Like screenchar(), but return the attribute. This is a rather
@@ -5591,7 +6021,7 @@ search({pattern} [, {flags} [, {stopline} [, {timeout}]]]) *search()*
'ignorecase', 'smartcase' and 'magic' are used.
- When the 'z' flag is not given seaching always starts in
+ When the 'z' flag is not given, searching always starts in
column zero and then matches before the cursor are skipped.
When the 'c' flag is present in 'cpo' the next search starts
after the match. Without the 'c' flag the next search starts
@@ -5906,11 +6336,13 @@ setline({lnum}, {text}) *setline()*
setloclist({nr}, {list} [, {action}[, {title}]]) *setloclist()*
Create or replace or add to the location list for window {nr}.
- When {nr} is zero the current window is used. For a location
- list window, the displayed location list is modified. For an
- invalid window number {nr}, -1 is returned. If {title} is
- given, it will be used to set |w:quickfix_title| after opening
- the location window.
+ {nr} can be the window number or the window ID.
+ When {nr} is zero the current window is used.
+
+ For a location list window, the displayed location list is
+ modified. For an invalid window number {nr}, -1 is returned. If
+ {title} is given, it will be used to set |w:quickfix_title|
+ after opening the location window.
Otherwise, same as |setqflist()|.
Also see |location-list|.
@@ -5999,12 +6431,18 @@ setqflist({list} [, {action}[, {title}]]) *setqflist()*
Note that the list is not exactly the same as what
|getqflist()| returns.
+ *E927*
If {action} is set to 'a', then the items from {list} are
added to the existing quickfix list. If there is no existing
- list, then a new list is created. If {action} is set to 'r',
- then the items from the current quickfix list are replaced
- with the items from {list}. If {action} is not present or is
- set to ' ', then a new list is created.
+ list, then a new list is created.
+
+ If {action} is set to 'r', then the items from the current
+ quickfix list are replaced with the items from {list}. This
+ can also be used to clear the list: >
+ :call setqflist([], 'r')
+<
+ If {action} is not present or is set to ' ', then a new list
+ is created.
If {title} is given, it will be used to set |w:quickfix_title|
after opening the quickfix window.
@@ -6017,7 +6455,7 @@ setqflist({list} [, {action}[, {title}]]) *setqflist()*
*setreg()*
-setreg({regname}, {value} [,{options}])
+setreg({regname}, {value} [, {options}])
Set the register {regname} to {value}.
{value} may be any value returned by |getreg()|, including
a |List|.
@@ -6074,6 +6512,7 @@ settabwinvar({tabnr}, {winnr}, {varname}, {val}) *settabwinvar()*
{val}.
Tabs are numbered starting with one. For the current tabpage
use |setwinvar()|.
+ {winnr} can be the window number or the window ID.
When {winnr} is zero the current window is used.
This also works for a global or local buffer option, but it
doesn't work for a global or local buffer variable.
@@ -6198,6 +6637,9 @@ sort({list} [, {func} [, {dict}]]) *sort()* *E702*
sorted numerical. This is like 'n' but a string containing
digits will be used as the number they represent.
+ When {func} is given and it is 'f' then all items will be
+ sorted numerical. All values must be a Number or a Float.
+
When {func} is a |Funcref| or a function name, this function
is called to compare items. The function is invoked with two
items as argument and must return zero if they are equal, 1 or
@@ -6355,7 +6797,6 @@ strchars({expr} [, {skipcc}]) *strchars()*
counted separately.
When {skipcc} set to 1, Composing characters are ignored.
Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
-
{skipcc} is only available after 7.4.755. For backward
compatibility, you can define a wrapper function: >
@@ -6373,6 +6814,13 @@ strchars({expr} [, {skipcc}]) *strchars()*
endfunction
endif
<
+strcharpart({src}, {start}[, {len}]) *strcharpart()*
+ Like |strpart()| but using character index and length instead
+ of byte index and length.
+ When a character index is used where a character does not
+ exist it is assumed to be one byte. For example: >
+ strcharpart('abc', -1, 2)
+< results in 'a'.
strdisplaywidth({expr}[, {col}]) *strdisplaywidth()*
The result is a Number, which is the number of display cells
@@ -6406,6 +6854,12 @@ strftime({format} [, {time}]) *strftime()*
< Not available on all systems. To check use: >
:if exists("*strftime")
+strgetchar({str}, {index}) *strgetchar()*
+ Get character {index} from {str}. This uses a character
+ index, not a byte index. Composing characters are considered
+ separate characters here.
+ Also see |strcharpart()| and |strchars()|.
+
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}.
@@ -6443,8 +6897,7 @@ string({expr}) Return {expr} converted to a String. If {expr} is a Number,
for infinite and NaN floating-point values representations
which use |str2float()|. Strings are also dumped literally,
only single quote is escaped, which does not allow using YAML
- for parsing back binary strings (including text when
- 'encoding' is not UTF-8). |eval()| should always work for
+ for parsing back binary strings. |eval()| should always work for
strings and floats though and this is the only official
method, use |msgpackdump()| or |json_encode()| if you need to
share data with other application.
@@ -6461,14 +6914,17 @@ strlen({expr}) The result is a Number, which is the length of the String
strpart({src}, {start}[, {len}]) *strpart()*
The result is a String, which is part of {src}, starting from
byte {start}, with the byte length {len}.
- When non-existing bytes are included, this doesn't result in
- an error, the bytes are simply omitted.
+ To count characters instead of bytes use |strcharpart()|.
+
+ When bytes are selected which do not exist, this doesn't
+ result in an error, the bytes are simply omitted.
If {len} is missing, the copy continues from {start} till the
end of the {src}. >
strpart("abcdefg", 3, 2) == "de"
strpart("abcdefg", -2, 4) == "ab"
strpart("abcdefg", 5, 4) == "fg"
strpart("abcdefg", 3) == "defg"
+
< Note: To get the first character, {start} must be 0. For
example, to get three bytes under and after the cursor: >
strpart(getline("."), col(".") - 1, 3)
@@ -6574,9 +7030,9 @@ synID({lnum}, {col}, {trans}) *synID()*
that's where the cursor can be in Insert mode, synID() returns
zero.
- When {trans} is non-zero, transparent items are reduced to the
+ When {trans} is |TRUE|, transparent items are reduced to the
item that they reveal. This is useful when wanting to know
- the effective color. When {trans} is zero, the transparent
+ the effective color. When {trans} is |FALSE|, the transparent
item is returned. This is useful when wanting to know which
syntax item is effective (e.g. inside parens).
Warning: This function can be very slow. Best speed is
@@ -6659,26 +7115,32 @@ synstack({lnum}, {col}) *synstack()*
valid positions.
system({cmd} [, {input}]) *system()* *E677*
- Get the output of the shell command {cmd} as a |string|. {cmd}
- will be run the same as in |jobstart()|. See |systemlist()|
- to get the output as a |List|.
-
- When {input} is given and is a string this string is written
- to a file and passed as stdin to the command. The string is
- written as-is, you need to take care of using the correct line
- separators yourself.
- If {input} is given and is a |List| it is written to the file
- in a way |writefile()| does with {binary} set to "b" (i.e.
- with a newline between each list item with newlines inside
- list items converted to NULs).
- Pipes are not used.
+ Get the output of {cmd} as a |string| (use |systemlist()| to
+ get a |List|). {cmd} is treated exactly as in |jobstart()|.
+ Not to be used for interactive commands.
+
+ If {input} is a string it is written to a pipe and passed as
+ stdin to the command. The string is written as-is, line
+ separators are not changed.
+ If {input} is a |List| it is written to the pipe as
+ |writefile()| does with {binary} set to "b" (i.e. with
+ a newline between each list item, and newlines inside list
+ items converted to NULs).
+ *E5677*
+ Note: system() cannot write to or read from backgrounded ("&")
+ shell commands, e.g.: >
+ :echo system("cat - &", "foo"))
+< which is equivalent to: >
+ $ echo foo | bash -c 'cat - &'
+< The pipes are disconnected (unless overridden by shell
+ redirection syntax) before input can reach it. Use
+ |jobstart()| instead.
Note: Use |shellescape()| or |::S| with |expand()| or
|fnamemodify()| to escape special characters in a command
argument. Newlines in {cmd} may cause the command to fail.
The characters in 'shellquote' and 'shellxquote' may also
cause trouble.
- This is not to be used for interactive commands.
The result is a String. Example: >
:let files = system("ls " . shellescape(expand('%:h')))
@@ -6693,9 +7155,6 @@ system({cmd} [, {input}]) *system()* *E677*
The command executed is constructed using several options when
{cmd} is a string: 'shell' 'shellcmdflag' {cmd}
- The command will be executed in "cooked" mode, so that a
- CTRL-C will interrupt the command (on Unix at least).
-
The resulting error code can be found in |v:shell_error|.
This function will fail in |restricted-mode|.
@@ -6816,7 +7275,7 @@ termopen({cmd}[, {opts}]) {Nvim} *termopen()*
and `$TERM` is set to "xterm-256color".
Returns the same values as |jobstart()|.
- See |nvim-terminal-emulator| for more information.
+ See |terminal-emulator| for more information.
tan({expr}) *tan()*
Return the tangent of {expr}, measured in radians, as a |Float|
@@ -6840,6 +7299,38 @@ tanh({expr}) *tanh()*
< -0.761594
+ *timer_start()*
+timer_start({time}, {callback} [, {options}])
+ Create a timer and return the timer ID.
+
+ {time} is the waiting time in milliseconds. This is the
+ minimum time before invoking the callback. When the system is
+ busy or Vim is not waiting for input the time will be longer.
+
+ {callback} is the function to call. It can be the name of a
+ function or a Funcref. It is called with one argument, which
+ is the timer ID. The callback is only invoked when Vim is
+ waiting for input.
+
+ {options} is a dictionary. Supported entries:
+ "repeat" Number of times to repeat calling the
+ callback. -1 means forever.
+
+ Example: >
+ func MyHandler(timer)
+ echo 'Handler called'
+ endfunc
+ let timer = timer_start(500, 'MyHandler',
+ \ {'repeat': 3})
+< This will invoke MyHandler() three times at 500 msec
+ intervals.
+ {only available when compiled with the |+timers| feature}
+
+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.
+
tolower({expr}) *tolower()*
The result is a copy of the String given, with all uppercase
characters turned into lowercase (just like applying |gu| to
@@ -7039,11 +7530,40 @@ wildmenumode() *wildmenumode()*
(Note, this needs the 'wildcharm' option set appropriately).
+win_findbuf({bufnr}) *win_findbuf()*
+ Returns a list with window IDs for windows that contain buffer
+ {bufnr}. When there is none the list is empty.
+
+win_getid([{win} [, {tab}]]) *win_getid()*
+ Get the window ID for the specified window.
+ When {win} is missing use the current window.
+ With {win} this is the window number. The top window has
+ number 1.
+ Without {tab} use the current tab, otherwise the tab with
+ number {tab}. The first tab has number one.
+ Return zero if the window cannot be found.
+
+win_gotoid({expr}) *win_gotoid()*
+ Go to window with ID {expr}. This may also change the current
+ tabpage.
+ Return 1 if successful, 0 if the window cannot be found.
+
+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.
+
+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.
+
*winbufnr()*
winbufnr({nr}) The result is a Number, which is the number of the buffer
- associated with window {nr}. When {nr} is zero, the number of
- the buffer in the current window is returned. When window
- {nr} doesn't exist, -1 is returned.
+ associated with window {nr}. {nr} can be the window number or
+ the window ID.
+ When {nr} is zero, the number of the buffer in the current
+ window is returned.
+ When window {nr} doesn't exist, -1 is returned.
Example: >
:echo "The file in the current window is " . bufname(winbufnr(0))
<
@@ -7054,6 +7574,7 @@ wincol() The result is a Number, which is the virtual column of the
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.
When {nr} is zero, the height of the current window is
returned. When window {nr} doesn't exist, -1 is returned.
An existing window always has a height of zero or more.
@@ -7133,6 +7654,7 @@ winsaveview() Returns a |Dictionary| that contains information to restore
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.
When {nr} is zero, the width of the current window is
returned. When window {nr} doesn't exist, -1 is returned.
An existing window always has a width of zero or more.
@@ -7208,7 +7730,11 @@ There are four types of features:
Example: >
:if has("gui_running")
< *has-patch*
-3. Included patches. The "patch123" feature means that patch 123 has been
+3. {Nvim} version. The "nvim-1.2.3" feature means that the Nvim version is
+ 1.2.3 or later. Example: >
+ :if has("nvim-1.2.3")
+<
+4. Included patches. The "patch123" feature means that patch 123 has been
included. Note that this form does not check the version of Vim, you need
to inspect |v:version| for that.
Example (checking version 6.2.148 or later): >
@@ -7216,7 +7742,7 @@ There are four types of features:
< Note that it's possible for patch 147 to be omitted even though 148 is
included.
-4. Beyond a certain version or at a certain version and including a specific
+5. Beyond a certain version or at a certain version and including a specific
patch. The "patch-7.4.237" feature means that the Vim version is 7.5 or
later, or it is version 7.4 and patch 237 was included.
Note that this only works for patch 7.4.237 and later, before that you
@@ -7247,7 +7773,7 @@ dialog_gui Compiled with GUI dialog support.
digraphs Compiled with support for digraphs.
eval Compiled with expression evaluation support. Always
true, of course!
-ex_extra Compiled with extra Ex commands |+ex_extra|.
+ex_extra |+ex_extra|, always true now
extra_search Compiled with support for |'incsearch'| and
|'hlsearch'|
farsi Compiled with Farsi support |farsi|.
@@ -7288,6 +7814,7 @@ multi_byte Compiled with support for 'encoding'
multi_byte_encoding 'encoding' is set to a multi-byte encoding.
multi_byte_ime Compiled with support for IME input method.
multi_lang Compiled with support for multiple languages.
+nvim This is Nvim. |has-patch|
ole Compiled with OLE automation support for Win32.
path_extra Compiled with up/downwards search in 'path' and 'tags'
persistent_undo Compiled with support for persistent undo history.
@@ -7323,12 +7850,14 @@ termresponse Compiled with support for |t_RV| and |v:termresponse|.
textobjects Compiled with support for |text-objects|.
tgetent Compiled with tgetent support, able to use a termcap
or terminfo file.
+timers Compiled with |timer_start()| support.
title Compiled with window title support |'title'|.
toolbar Compiled with support for |gui-toolbar|.
unix Unix version of Vim.
user_commands User-defined commands.
vertsplit Compiled with vertically split windows |:vsplit|.
vim_starting True while initial source'ing takes place. |startup|
+ *vim_starting*
virtualedit Compiled with 'virtualedit' option.
visual Compiled with Visual mode.
visualextra Compiled with extra Visual mode commands.
@@ -7953,7 +8482,7 @@ This does NOT work: >
From Vim version 4.5 until 5.0, every Ex command in
between the ":if" and ":endif" is ignored. These two
commands were just to allow for future expansions in a
- backwards compatible way. Nesting was allowed. Note
+ backward compatible way. Nesting was allowed. Note
that any ":else" or ":elseif" was ignored, the "else"
part was not executed either.
@@ -8020,14 +8549,6 @@ This does NOT work: >
endfor
< Note that reordering the list (e.g., with sort() or
reverse()) may have unexpected effects.
- Note that the type of each list item should be
- identical to avoid errors for the type of {var}
- changing. Unlet the variable at the end of the loop
- to allow multiple item types: >
- for item in ["foo", ["bar"]]
- echo item
- unlet item " E706 without this
- endfor
:for [{var1}, {var2}, ...] in {listlist}
:endfo[r]