robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
aa1d8a2702
master
1-- Defines all "vimfn" (builtin/"eval"/"Vimscript") functions. 2-- 3--- @class vim.EvalFn 4--- @field name? string 5--- @field args? integer|integer[] (default: 0) Number of arguments, list with maximum and minimum number of arguments or list with a minimum number of arguments only. 6--- @field base? integer For methods: the argument to use as the base argument (1-indexed): base->method(). Defaults to BASE_NONE (function cannot be used as a method). 7--- @field func? string (default: "f_{funcname}") C function which implements the vimfn. 8--- @field func_float? string Floating-point C function. Sets func="float_op_wrapper". 9--- @field func_lua? string Function name in `vim._core.vimfn.*` (e.g. "f_hostname"). Sets func="lua_wrapper". 10--- @field fast? boolean Function can run in |api-fast| events. Defaults to false. 11--- @field deprecated? true 12--- @field returns? string|false 13--- @field returns_desc? string 14--- @field generics? string[] Used to write `---@generic` annotations over a function. 15--- @field signature? string 16--- @field desc? string 17--- @field params [string, string, string?][] Each entry is `{name, type, desc?}`; `desc` is only present in API-meta entries. 18--- @field notes? string[] 19--- @field see? string[] 20--- 21--- Recommended alternatives if calling from Lua. 22--- `false` means there is no useful Lua replacement to suggest. 23--- @field see_lua? string[]|false 24--- @field lua? false Do not render type information 25--- @field tags? string[] Extra tags 26--- @field data? string Used by gen_eval.lua 27 28-- Usable with the base key: use the last function argument as the method base. 29-- Value is from funcs.h file. "BASE_" prefix is omitted. 30-- local LAST = "BASE_LAST" (currently unused after port of v8.2.1168) 31 32local M ={} 33 34local VARARGS ={ { '...' , 'any' } } 35 36--- @type table<string,vim.EvalFn> 37M . funcs ={ 38abs ={ 39args =1 , 40base =1 , 41desc =[=[ 42Return the absolute value of {expr}. When {expr} evaluates to 43a |Float| abs() returns a |Float|. When {expr} can be 44converted to a |Number| abs() returns a |Number|. Otherwise 45abs() gives an error message and returns -1. 46Examples: >vim 47echo abs(1.456) 48< 1.456 >vim 49echo abs(-5.456) 50< 5.456 >vim 51echo abs(-4) 52< 4 53 54]=] , 55name ='abs' , 56params ={ { 'expr' , 'number' } } , 57signature ='abs({expr})' , 58returns ='number' , 59see_lua ={ '|math.abs()|' } , 60} , 61acos ={ 62args =1 , 63base =1 , 64desc =[=[ 65Return the arc cosine of {expr} measured in radians, as a 66|Float| in the range of [0, pi]. 67{expr} must evaluate to a |Float| or a |Number| in the range 68[-1, 1]. 69Returns NaN if {expr} is outside the range [-1, 1]. Returns 700.0 if {expr} is not a |Float| or a |Number|. 71Examples: >vim 72echo acos(0) 73< 1.570796 >vim 74echo acos(-0.5) 75< 2.094395 76 77]=] , 78func_float ='acos' , 79name ='acos' , 80params ={ { 'expr' , 'number' } } , 81returns ='number' , 82signature ='acos({expr})' , 83see_lua ={ '|math.acos()|' } , 84} , 85add ={ 86args =2 , 87base =1 , 88desc =[=[ 89Append the item {expr} to |List| or |Blob| {object}. Returns 90the resulting |List| or |Blob|. Examples: >vim 91let alist = add([1, 2, 3], item) 92call add(mylist, "woodstock") 93<Note that when {expr} is a |List| it is appended as a single 94item. Use |extend()| to concatenate |Lists|. 95When {object} is a |Blob| then {expr} must be a number. 96Use |insert()| to add an item at another position. 97Returns 1 if {object} is not a |List| or a |Blob|. 98 99]=] , 100name ='add' , 101params ={ { 'object' , 'any' } , { 'expr' , 'any' } } , 102returns ='any' , 103returns_desc =[=[Resulting |List| or |Blob|, or 1 if {object} is not a |List| or a |Blob|.]=] , 104signature ='add({object}, {expr})' , 105see_lua ={ '|table.insert()| for lists and `..` for blobs' } , 106} , 107[ 'and' ] ={ 108args =2 , 109base =1 , 110desc =[=[ 111Bitwise AND on the two arguments. The arguments are converted 112to a number. A List, Dict or Float argument causes an error. 113Also see |or()| and |xor()|. 114Example: >vim 115let flag = and(bits, 0x80) 116< 117]=] , 118name ='and' , 119params ={ { 'expr' , 'number' } , { 'expr' , 'number' } } , 120returns ='integer' , 121signature ='and({expr}, {expr})' , 122see_lua ={ '|bit.band()|' } , 123} , 124api_info ={ 125desc =[=[ 126Returns Dictionary of |api-metadata|. 127 128View it in a nice human-readable format: >vim 129lua vim.print(vim.fn.api_info()) 130< 131]=] , 132fast =true , 133name ='api_info' , 134params ={} , 135returns ='table' , 136signature ='api_info()' , 137} , 138append ={ 139args =2 , 140base =2 , 141desc =[=[ 142When {text} is a |List|: Append each item of the |List| as a 143text line below line {lnum} in the current buffer. 144Otherwise append {text} as one text line below line {lnum} in 145the current buffer. 146Any type of item is accepted and converted to a String. 147{lnum} can be zero to insert a line before the first one. 148{lnum} is used like with |getline()|. 149Returns 1 for failure ({lnum} out of range or out of memory), 1500 for success. When {text} is an empty list zero is returned, 151no matter the value of {lnum}. Example: >vim 152let failed = append(line('$'), "# THE END") 153let failed = append(0, ["Chapter 1", "the beginning"]) 154< 155 156]=] , 157name ='append' , 158params ={ { 'lnum' , 'integer|string' } , { 'text' , 'string|string[]' } } , 159returns ='0|1' , 160signature ='append({lnum}, {text})' , 161see_lua ={ '|nvim_buf_set_lines()|' } , 162} , 163appendbufline ={ 164args =3 , 165base =3 , 166desc =[=[ 167Like |append()| but append the text in buffer {buf}. 168 169This function works only for loaded buffers. First call 170|bufload()| if needed. 171 172For the use of {buf}, see |bufname()|. 173 174{lnum} is the line number to append below. Note that using 175|line()| would use the current buffer, not the one appending 176to. Use "$" to append at the end of the buffer. Other string 177values are not supported. 178 179On success 0 is returned, on failure 1 is returned. 180 181If {buf} is not a valid buffer or {lnum} is not valid, an 182error message is given. Example: >vim 183let failed = appendbufline(13, 0, "# THE START") 184<However, when {text} is an empty list then no error is given 185for an invalid {lnum}, since {lnum} isn't actually used. 186 187]=] , 188name ='appendbufline' , 189params ={ { 'buf' , 'integer|string' } , { 'lnum' , 'integer' } , { 'text' , 'string' } } , 190returns ='0|1' , 191signature ='appendbufline({buf}, {lnum}, {text})' , 192see_lua ={ '|nvim_buf_set_lines()|' } , 193} , 194argc ={ 195args ={ 0 , 1 } , 196desc =[=[ 197The result is the number of files in the argument list. See 198|arglist|. 199If {winid} is not supplied, the argument list of the current 200window is used. 201If {winid} is -1, the global argument list is used. 202Otherwise {winid} (a |window-number| or |window-ID|) specifies 203the window of which the argument list is used. 204Returns -1 if the {winid} argument is invalid. 205]=] , 206name ='argc' , 207params ={ { 'winid' , 'integer' } } , 208returns ='integer' , 209signature ='argc([{winid}])' , 210} , 211argidx ={ 212desc =[=[ 213The result is the current index in the argument list. 0 is 214the first file. |argc()| - 1 is the last one. See |arglist|. 215]=] , 216name ='argidx' , 217params ={} , 218returns ='integer' , 219signature ='argidx()' , 220} , 221arglistid ={ 222args ={ 0 , 2 } , 223desc =[=[ 224Return the argument list ID. This is a number which 225identifies the argument list being used. Zero is used for the 226global argument list. See |arglist|. 227Returns -1 if the arguments are invalid. 228 229Without arguments use the current window. 230With {winnr} only use this window in the current tabpage. 231With {winnr} and {tabnr} use the window in the specified tab 232page. 233{winnr} is a |window-number| or |window-ID|. 234]=] , 235name ='arglistid' , 236params ={ { 'winnr' , 'integer' } , { 'tabnr' , 'integer' } } , 237returns ='integer' , 238signature ='arglistid([{winnr} [, {tabnr}]])' , 239} , 240argv ={ 241args ={ 0 , 2 } , 242desc =[=[ 243The result is the {nr}th file in the argument list. See 244|arglist|. "argv(0)" is the first one. Example: >vim 245let i = 0 246while i < argc() 247let f = escape(fnameescape(argv(i)), '.') 248exe 'amenu Arg.' .. f .. ' :e ' .. f .. '<CR>' 249let i = i + 1 250endwhile 251<Without the {nr} argument, or when {nr} is -1, a |List| with 252the whole |arglist| is returned. 253 254The {winid} argument is a |window-ID|, see |argc()|. 255For the Vim command line arguments see |v:argv|. 256 257Returns an empty string if {nr}th argument is not present in 258the argument list. Returns an empty List if the {winid} 259argument is invalid. 260]=] , 261name ='argv' , 262params ={ { 'nr' , 'integer' } , { 'winid' , 'integer' } } , 263returns ='string|string[]' , 264signature ='argv([{nr} [, {winid}]])' , 265} , 266asin ={ 267args =1 , 268base =1 , 269desc =[=[ 270Return the arc sine of {expr} measured in radians, as a |Float| 271in the range of [-pi/2, pi/2]. 272{expr} must evaluate to a |Float| or a |Number| in the range 273[-1, 1]. 274Returns NaN if {expr} is outside the range [-1, 1]. Returns 2750.0 if {expr} is not a |Float| or a |Number|. 276Examples: >vim 277echo asin(0.8) 278< 0.927295 >vim 279echo asin(-0.5) 280< -0.523599 281 282]=] , 283func_float ='asin' , 284name ='asin' , 285params ={ { 'expr' , 'any' } } , 286returns ='number' , 287signature ='asin({expr})' , 288see_lua ={ '|math.asin()|' } , 289} , 290assert_beeps ={ 291args =1 , 292base =1 , 293desc =[=[ 294Run {cmd} and add an error message to |v:errors| if it does 295NOT produce a beep or visual bell. 296Also see |assert_fails()|, |assert_nobeep()| and 297|assert-return|. 298 299]=] , 300name ='assert_beeps' , 301params ={ { 'cmd' , 'string' } } , 302returns ='0|1' , 303signature ='assert_beeps({cmd})' , 304} , 305assert_equal ={ 306args ={ 2 , 3 } , 307base =2 , 308desc =[=[ 309When {expected} and {actual} are not equal an error message is 310added to |v:errors| and 1 is returned. Otherwise zero is 311returned. |assert-return| 312The error is in the form "Expected {expected} but got 313{actual}". When {msg} is present it is prefixed to that, 314along with the location of the assert when run from a script. 315 316There is no automatic conversion, the String "4" is different 317from the Number 4. And the number 4 is different from the 318Float 4.0. The value of 'ignorecase' is not used here, case 319always matters. 320Example: >vim 321call assert_equal('foo', 'bar', 'baz') 322<Will add the following to |v:errors|: > 323test.vim line 12: baz: Expected 'foo' but got 'bar' 324< 325]=] , 326name ='assert_equal' , 327params ={ { 'expected' , 'any' } , { 'actual' , 'any' } , { 'msg' , 'any' } } , 328returns ='0|1' , 329signature ='assert_equal({expected}, {actual} [, {msg}])' , 330see_lua ={ '|assert()| with |vim.deep_equal()|' } , 331} , 332assert_equalfile ={ 333args ={ 2 , 3 } , 334base =1 , 335desc =[=[ 336When the files {fname_one} and {fname_two} do not contain 337exactly the same text an error message is added to |v:errors|. 338Also see |assert-return|. 339When {fname_one} or {fname_two} does not exist the error will 340mention that. 341 342]=] , 343name ='assert_equalfile' , 344params ={ { 'fname_one' , 'string' } , { 'fname_two' , 'string' } } , 345returns ='0|1' , 346signature ='assert_equalfile({fname_one}, {fname_two})' , 347} , 348assert_exception ={ 349args ={ 1 , 2 } , 350desc =[=[ 351When v:exception does not contain the string {error} an error 352message is added to |v:errors|. Also see |assert-return|. 353This can be used to assert that a command throws an exception. 354Using the error number, followed by a colon, avoids problems 355with translations: >vim 356try 357commandthatfails 358call assert_false(1, 'command should have failed') 359catch 360call assert_exception('E492:') 361endtry 362< 363]=] , 364name ='assert_exception' , 365params ={ { 'error' , 'any' } , { 'msg' , 'any' } } , 366returns ='0|1' , 367signature ='assert_exception({error} [, {msg}])' , 368see_lua =false , 369} , 370assert_fails ={ 371args ={ 1 , 5 } , 372base =1 , 373desc =[=[ 374Run {cmd} and add an error message to |v:errors| if it does 375NOT produce an error or when {error} is not found in the 376error message. Also see |assert-return|. 377 378When {error} is a string it must be found literally in the 379first reported error. Most often this will be the error code, 380including the colon, e.g. "E123:". >vim 381call assert_fails('bad cmd', 'E987:') 382< 383When {error} is a |List| with one or two strings, these are 384used as patterns. The first pattern is matched against the 385first reported error: >vim 386call assert_fails('cmd', ['E987:.*expected bool']) 387<The second pattern, if present, is matched against the last 388reported error. To only match the last error use an empty 389string for the first error: >vim 390call assert_fails('cmd', ['', 'E987:']) 391< 392If {msg} is empty then it is not used. Do this to get the 393default message when passing the {lnum} argument. 394*E1115* 395When {lnum} is present and not negative, and the {error} 396argument is present and matches, then this is compared with 397the line number at which the error was reported. That can be 398the line number in a function or in a script. 399*E1116* 400When {context} is present it is used as a pattern and matched 401against the context (script name or function name) where 402{lnum} is located in. 403 404Note that beeping is not considered an error, and some failing 405commands only beep. Use |assert_beeps()| for those. 406 407]=] , 408name ='assert_fails' , 409params ={ 410{ 'cmd' , 'string' } , 411{ 'error' , 'any' } , 412{ 'msg' , 'any' } , 413{ 'lnum' , 'integer' } , 414{ 'context' , 'any' } , 415} , 416returns ='0|1' , 417signature ='assert_fails({cmd} [, {error} [, {msg} [, {lnum} [, {context}]]]])' , 418see_lua =false , 419} , 420assert_false ={ 421args ={ 1 , 2 } , 422base =1 , 423desc =[=[ 424When {actual} is not false an error message is added to 425|v:errors|, like with |assert_equal()|. 426The error is in the form "Expected False but got {actual}". 427When {msg} is present it is prefixed to that, along with the 428location of the assert when run from a script. 429Also see |assert-return|. 430 431A value is false when it is zero. When {actual} is not a 432number the assert fails. 433 434]=] , 435name ='assert_false' , 436params ={ { 'actual' , 'any' } , { 'msg' , 'any' } } , 437returns ='0|1' , 438signature ='assert_false({actual} [, {msg}])' , 439see_lua ={ '|assert()|' } , 440} , 441assert_inrange ={ 442args ={ 3 , 4 } , 443base =3 , 444desc =[=[ 445This asserts number and |Float| values. When {actual} is lower 446than {lower} or higher than {upper} an error message is added 447to |v:errors|. Also see |assert-return|. 448The error is in the form "Expected range {lower} - {upper}, 449but got {actual}". When {msg} is present it is prefixed to 450that. 451]=] , 452name ='assert_inrange' , 453params ={ 454{ 'lower' , 'number' } , 455{ 'upper' , 'number' } , 456{ 'actual' , 'number' } , 457{ 'msg' , 'string' } , 458} , 459returns ='0|1' , 460signature ='assert_inrange({lower}, {upper}, {actual} [, {msg}])' , 461see_lua ={ '|assert()|' } , 462} , 463assert_match ={ 464args ={ 2 , 3 } , 465base =2 , 466desc =[=[ 467When {pattern} does not match {actual} an error message is 468added to |v:errors|. Also see |assert-return|. 469The error is in the form "Pattern {pattern} does not match 470{actual}". When {msg} is present it is prefixed to that, 471along with the location of the assert when run from a script. 472 473{pattern} is used as with |expr-=~|: The matching is always done 474like 'magic' was set and 'cpoptions' is empty, no matter what 475the actual value of 'magic' or 'cpoptions' is. 476 477{actual} is used as a string, automatic conversion applies. 478Use "^" and "$" to match with the start and end of the text. 479Use both to match the whole text. 480 481Example: >vim 482call assert_match('^f.*o$', 'foobar') 483<Will result in a string to be added to |v:errors|: > 484test.vim line 12: Pattern '^f.*o$' does not match 'foobar' 485< 486]=] , 487name ='assert_match' , 488params ={ { 'pattern' , 'string' } , { 'actual' , 'string' } , { 'msg' , 'string' } } , 489returns ='0|1' , 490signature ='assert_match({pattern}, {actual} [, {msg}])' , 491} , 492assert_nobeep ={ 493args =1 , 494base =1 , 495desc =[=[ 496Run {cmd} and add an error message to |v:errors| if it 497produces a beep or visual bell. 498Also see |assert_beeps()|. 499 500]=] , 501name ='assert_nobeep' , 502params ={ { 'cmd' , 'string' } } , 503returns ='0|1' , 504signature ='assert_nobeep({cmd})' , 505} , 506assert_notequal ={ 507args ={ 2 , 3 } , 508base =2 , 509desc =[=[ 510The opposite of `assert_equal()`: add an error message to 511|v:errors| when {expected} and {actual} are equal. 512Also see |assert-return|. 513 514]=] , 515name ='assert_notequal' , 516params ={ { 'expected' , 'any' } , { 'actual' , 'any' } , { 'msg' , 'any' } } , 517returns ='0|1' , 518signature ='assert_notequal({expected}, {actual} [, {msg}])' , 519} , 520assert_notmatch ={ 521args ={ 2 , 3 } , 522base =2 , 523desc =[=[ 524The opposite of `assert_match()`: add an error message to 525|v:errors| when {pattern} matches {actual}. 526Also see |assert-return|. 527 528]=] , 529name ='assert_notmatch' , 530params ={ { 'pattern' , 'string' } , { 'actual' , 'string' } , { 'msg' , 'string' } } , 531returns ='0|1' , 532signature ='assert_notmatch({pattern}, {actual} [, {msg}])' , 533} , 534assert_report ={ 535args =1 , 536base =1 , 537desc =[=[ 538Report a test failure directly, using String {msg}. 539Always returns one. 540 541]=] , 542name ='assert_report' , 543params ={ { 'msg' , 'string' } } , 544returns ='0|1' , 545signature ='assert_report({msg})' , 546} , 547assert_true ={ 548args ={ 1 , 2 } , 549base =1 , 550desc =[=[ 551When {actual} is not true an error message is added to 552|v:errors|, like with |assert_equal()|. 553Also see |assert-return|. 554A value is |TRUE| when it is a non-zero number or |v:true|. 555When {actual} is not a number or |v:true| the assert fails. 556When {msg} is given it is prefixed to the default message, 557along with the location of the assert when run from a script. 558 559]=] , 560name ='assert_true' , 561params ={ { 'actual' , 'any' } , { 'msg' , 'string' } } , 562returns ='0|1' , 563signature ='assert_true({actual} [, {msg}])' , 564see_lua ={ '|assert()|' } , 565} , 566atan ={ 567args =1 , 568base =1 , 569desc =[=[ 570Return the principal value of the arc tangent of {expr}, in 571the range [-pi/2, +pi/2] radians, as a |Float|. 572{expr} must evaluate to a |Float| or a |Number|. 573Returns 0.0 if {expr} is not a |Float| or a |Number|. 574Examples: >vim 575echo atan(100) 576< 1.560797 >vim 577echo atan(-4.01) 578< -1.326405 579 580]=] , 581func_float ='atan' , 582name ='atan' , 583params ={ { 'expr' , 'number' } } , 584returns ='number' , 585signature ='atan({expr})' , 586see_lua ={ '|math.atan()|' } , 587} , 588atan2 ={ 589args =2 , 590base =1 , 591desc =[=[ 592Return the arc tangent of {expr1} / {expr2}, measured in 593radians, as a |Float| in the range [-pi, pi]. 594{expr1} and {expr2} must evaluate to a |Float| or a |Number|. 595Returns 0.0 if {expr1} or {expr2} is not a |Float| or a 596|Number|. 597Examples: >vim 598echo atan2(-1, 1) 599< -0.785398 >vim 600echo atan2(1, -1) 601< 2.356194 602 603]=] , 604name ='atan2' , 605params ={ { 'expr1' , 'number' } , { 'expr2' , 'number' } } , 606returns ='number' , 607signature ='atan2({expr1}, {expr2})' , 608see_lua ={ '|math.atan2()|' } , 609} , 610blob2list ={ 611args =1 , 612base =1 , 613desc =[=[ 614Return a List containing the number value of each byte in Blob 615{blob}. Examples: >vim 616blob2list(0z0102.0304) " returns [1, 2, 3, 4] 617blob2list(0z) " returns [] 618<Returns an empty List on error. |list2blob()| does the 619opposite. 620 621]=] , 622name ='blob2list' , 623params ={ { 'blob' , 'any' } } , 624returns ='any[]' , 625signature ='blob2list({blob})' , 626see_lua =false , 627} , 628browse ={ 629args =4 , 630desc =[=[ 631Put up a file requester. This only works when "has("browse")" 632returns |TRUE| (only in some GUI versions). 633The input fields are: 634{save} when |TRUE|, select file to write 635{title} title for the requester 636{initdir} directory to start browsing in 637{default} default file name 638An empty string is returned when the "Cancel" button is hit, 639something went wrong, or browsing is not possible. 640]=] , 641name ='browse' , 642params ={ 643{ 'save' , 'any' } , 644{ 'title' , 'string' } , 645{ 'initdir' , 'string' } , 646{ 'default' , 'string' } , 647} , 648returns ='0|1' , 649signature ='browse({save}, {title}, {initdir}, {default})' , 650} , 651browsedir ={ 652args =2 , 653desc =[=[ 654Put up a directory requester. This only works when 655"has("browse")" returns |TRUE| (only in some GUI versions). 656On systems where a directory browser is not supported a file 657browser is used. In that case: select a file in the directory 658to be used. 659The input fields are: 660{title} title for the requester 661{initdir} directory to start browsing in 662When the "Cancel" button is hit, something went wrong, or 663browsing is not possible, an empty string is returned. 664]=] , 665name ='browsedir' , 666params ={ { 'title' , 'string' } , { 'initdir' , 'string' } } , 667returns ='0|1' , 668signature ='browsedir({title}, {initdir})' , 669} , 670bufadd ={ 671args =1 , 672base =1 , 673desc =[=[ 674Adds buffer {name} to the |buffer-list| literally: no special 675chars or expansion are applied (including "~"). Returns the 676new (or existing matching) buffer number, or 0 on error. 677 678The buffer is not loaded and 'buflisted' is not set. When 679{name} is an empty string, a new buffer is always created. 680 681Example (Lua): >lua 682local buf = vim.fn.bufadd(vim.fs.normalize('someName')) 683-- Set 'buflisted'; trigger BufReadPre/BufReadPost/FileType. 684vim.api.nvim_buf_call(buf, vim.cmd.edit) 685< 686]=] , 687name ='bufadd' , 688params ={ { 'name' , 'string' } } , 689returns ='integer' , 690signature ='bufadd({name})' , 691see_lua =false , 692} , 693bufexists ={ 694args =1 , 695base =1 , 696desc =[=[ 697Checks whether a buffer with the name or number {buf} exists. 698Returns |TRUE| if the buffer exists, |FALSE| otherwise. 699If the {buf} argument is a number, buffer numbers are used. 700Number zero is the alternate buffer for the current window. 701 702If the {buf} argument is a string it must match a buffer name 703exactly. The name can be: 704- Relative to the current directory. 705- A full path. 706- The name of a buffer with 'buftype' set to "nofile". 707- A URL name. 708Unlisted buffers will be found. 709Note that help files are listed by their short name in the 710output of |:buffers|, but bufexists() requires using their 711long name to be able to find them. 712bufexists() may report a buffer exists, but to use the name 713with a |:buffer| command you may need to use |expand()|. Esp 714for MS-Windows 8.3 names in the form "c:\DOCUME~1" 715Use "bufexists(0)" to test for the existence of an alternate 716file name. 717 718]=] , 719name ='bufexists' , 720params ={ { 'buf' , 'any' } } , 721returns ='0|1' , 722signature ='bufexists({buf})' , 723see_lua ={ '|nvim_buf_is_valid()| after resolving {buf} to a bufnr' } , 724} , 725buffer_exists ={ 726args =1 , 727base =1 , 728deprecated =true , 729desc =[=[ 730Obsolete name for |bufexists()|. 731]=] , 732func ='f_bufexists' , 733name ='buffer_exists' , 734params =VARARGS , 735returns ='0|1' , 736signature ='buffer_exists({buf})' , 737see_lua ={ '|nvim_buf_is_valid()| after resolving {buf} to a bufnr' } , 738} , 739buffer_name ={ 740args ={ 0 , 1 } , 741base =1 , 742deprecated =true , 743desc =[=[ 744Obsolete name for |bufname()|. 745]=] , 746func ='f_bufname' , 747name ='buffer_name' , 748params =VARARGS , 749returns ='string' , 750signature ='buffer_name([{buf}])' , 751see_lua ={ '|nvim_buf_get_name()| after resolving {buf} to a bufnr' } , 752} , 753buffer_number ={ 754args ={ 0 , 1 } , 755base =1 , 756deprecated =true , 757desc =[=[ 758Obsolete name for |bufnr()|. 759]=] , 760func ='f_bufnr' , 761name ='buffer_number' , 762params =VARARGS , 763returns ='integer' , 764signature ='buffer_number([{buf} [, {create}]])' , 765see_lua ={ 766'|nvim_get_current_buf()| when omitted, or |nvim_create_buf()| with |nvim_buf_set_name()| for creating; name lookup, "$", "%", "#", and {create} semantics differ' , 767} , 768} , 769buflisted ={ 770args =1 , 771base =1 , 772desc =[=[ 773Checks whether a buffer called {buf} exists and is listed 774(has the 'buflisted' option set). Returns |TRUE| if so, 775|FALSE| otherwise. 776The {buf} argument is used like with |bufexists()|. 777 778]=] , 779name ='buflisted' , 780params ={ { 'buf' , 'any' } } , 781returns ='0|1' , 782signature ='buflisted({buf})' , 783see_lua ={ '|vim.bo| or |nvim_get_option_value()| after resolving {buf} to a bufnr' } , 784} , 785bufload ={ 786args =1 , 787base =1 , 788desc =[=[ 789Ensure the buffer {buf} is loaded. When the buffer name 790refers to an existing file then the file is read. Otherwise 791the buffer will be empty. If the buffer was already loaded 792then there is no change. If the buffer is not related to a 793file then no file is read (e.g., when 'buftype' is "nofile"). 794If there is an existing swap file for the file of the buffer, 795there will be no dialog, the buffer will be loaded anyway. 796The {buf} argument is used like with |bufexists()|. 797 798]=] , 799name ='bufload' , 800params ={ { 'buf' , 'any' } } , 801returns =false , 802signature ='bufload({buf})' , 803} , 804bufloaded ={ 805args =1 , 806base =1 , 807desc =[=[ 808Checks whether a buffer called {buf} exists and is loaded 809(shown in a window or hidden). Returns |TRUE| if so, 810|FALSE| otherwise. 811The {buf} argument is used like with |bufexists()|. 812 813]=] , 814name ='bufloaded' , 815params ={ { 'buf' , 'any' } } , 816returns ='0|1' , 817signature ='bufloaded({buf})' , 818see_lua ={ '|nvim_buf_is_loaded()| after resolving {buf} to a bufnr' } , 819} , 820bufname ={ 821args ={ 0 , 1 } , 822base =1 , 823desc =[=[ 824The result is the name of a buffer. Mostly as it is displayed 825by the `:ls` command, but not using special names such as 826"[No Name]". If the buffer represents a directory, the name 827ends with a path separator, unless it was changed by |:file| or 828|nvim_buf_set_name()|. 829If {buf} is omitted the current buffer is used. 830If {buf} is a Number, that buffer number's name is given. 831Number zero is the alternate buffer for the current window. 832If {buf} is a String, it is used as a |file-pattern| to match 833with the buffer names. This is always done like 'magic' is 834set and 'cpoptions' is empty. When there is more than one 835match an empty string is returned. 836"" or "%" can be used for the current buffer, "#" for the 837alternate buffer. 838A full match is preferred, otherwise a match at the start, end 839or middle of the buffer name is accepted. If you only want a 840full match then put "^" at the start and "$" at the end of the 841pattern. 842Listed buffers are found first. If there is a single match 843with a listed buffer, that one is returned. Next unlisted 844buffers are searched for. 845If the {buf} is a String, but you want to use it as a buffer 846number, force it to be a Number by adding zero to it: >vim 847echo bufname("3" + 0) 848<If the buffer doesn't exist, or doesn't have a name, an empty 849string is returned. >vim 850echo bufname("#") " alternate buffer name 851echo bufname(3) " name of buffer 3 852echo bufname("%") " name of current buffer 853echo bufname("file2") " name of buffer where "file2" matches. 854< 855]=] , 856name ='bufname' , 857params ={ { 'buf' , 'integer|string' } } , 858returns ='string' , 859signature ='bufname([{buf}])' , 860see_lua ={ '|nvim_buf_get_name()| after resolving {buf} to a bufnr' } , 861} , 862bufnr ={ 863args ={ 0 , 2 } , 864base =1 , 865desc =[=[ 866The result is the number of a buffer, as it is displayed by 867the `:ls` command. For the use of {buf}, see |bufname()| 868above. 869If the buffer doesn't exist, -1 is returned. Or, if the 870{create} argument is present and TRUE, a new, unlisted, 871buffer is created and its number is returned. Example: >vim 872let newbuf = bufnr('Scratch001', 1) 873<Using an empty name uses the current buffer. To create a new 874buffer with an empty name use |bufadd()|. 875 876bufnr("$") is the last buffer: >vim 877let last_buffer = bufnr("$") 878<The result is a Number, which is the highest buffer number 879of existing buffers. Note that not all buffers with a smaller 880number necessarily exist, because ":bwipeout" may have removed 881them. Use |bufexists()| to test for the existence of a buffer. 882 883]=] , 884name ='bufnr' , 885params ={ { 'buf' , 'integer|string' } , { 'create' , 'any' } } , 886returns ='integer' , 887signature ='bufnr([{buf} [, {create}]])' , 888see_lua ={ 889'|nvim_get_current_buf()| when omitted, or |nvim_create_buf()| with |nvim_buf_set_name()| for creating; name lookup, "$", "%", "#", and {create} semantics differ' , 890} , 891} , 892bufwinid ={ 893args =1 , 894base =1 , 895desc =[=[ 896Returns the |window-ID| of the first window associated with 897buffer {buf}. For the use of {buf}, see |bufname()| above. 898If buffer {buf} doesn't exist or there is no such window, -1 899is returned. Example: >vim 900 901echo "A window containing buffer 1 is " .. (bufwinid(1)) 902< 903Only deals with the current tabpage. See |win_findbuf()| for 904finding more. 905 906]=] , 907name ='bufwinid' , 908params ={ { 'buf' , 'any' } } , 909returns ='integer' , 910signature ='bufwinid({buf})' , 911see_lua ={ 912'|nvim_tabpage_list_wins()| with |nvim_win_get_buf()| after resolving {buf}; only the current tabpage is checked and no-match semantics differ' , 913} , 914} , 915bufwinnr ={ 916args =1 , 917base =1 , 918desc =[=[ 919Like |bufwinid()| but returns a |window-number| instead of a 920|window-ID|. 921If buffer {buf} doesn't exist or there is no such window, -1 922is returned. Example: >vim 923 924echo "A window containing buffer 1 is " .. (bufwinnr(1)) 925 926<The number can be used with |CTRL-W_w| and ":wincmd w" 927|:wincmd|. 928 929]=] , 930name ='bufwinnr' , 931params ={ { 'buf' , 'any' } } , 932returns ='integer' , 933signature ='bufwinnr({buf})' , 934see_lua ={ 935'|nvim_tabpage_list_wins()| with |nvim_win_get_buf()| and |nvim_win_get_number()| after resolving {buf}; only the current tabpage is checked and no-match semantics differ' , 936} , 937} , 938byte2line ={ 939args =1 , 940base =1 , 941desc =[=[ 942Return the line number that contains the character at byte 943count {byte} in the current buffer. This includes the 944end-of-line character, depending on the 'fileformat' option 945for the current buffer. The first character has byte count 946one. 947Also see |line2byte()|, |go| and |:goto|. 948 949Returns -1 if the {byte} value is invalid. 950 951]=] , 952name ='byte2line' , 953params ={ { 'byte' , 'any' } } , 954returns ='integer' , 955signature ='byte2line({byte})' , 956} , 957byteidx ={ 958args ={ 2 , 3 } , 959base =1 , 960desc =[=[ 961Return byte index of the {nr}th character in the String 962{expr}. Use zero for the first character, it then returns 963zero. 964If there are no multibyte characters the returned value is 965equal to {nr}. 966Composing characters are not counted separately, their byte 967length is added to the preceding base character. See 968|byteidxcomp()| below for counting composing characters 969separately. 970When {utf16} is present and TRUE, {nr} is used as the UTF-16 971index in the String {expr} instead of as the character index. 972The UTF-16 index is the index in the string when it is encoded 973with 16-bit words. If the specified UTF-16 index is in the 974middle of a character (e.g. in a 4-byte character), then the 975byte index of the first byte in the character is returned. 976Refer to |string-offset-encoding| for more information. 977Example : >vim 978echo matchstr(str, ".", byteidx(str, 3)) 979<will display the fourth character. Another way to do the 980same: >vim 981let s = strpart(str, byteidx(str, 3)) 982echo strpart(s, 0, byteidx(s, 1)) 983<Also see |strgetchar()| and |strcharpart()|. 984 985If there are less than {nr} characters -1 is returned. 986If there are exactly {nr} characters the length of the string 987in bytes is returned. 988See |charidx()| and |utf16idx()| for getting the character and 989UTF-16 index respectively from the byte index. 990Examples: >vim 991echo byteidx('a😊😊', 2) " returns 5 992echo byteidx('a😊😊', 2, 1) " returns 1 993echo byteidx('a😊😊', 3, 1) " returns 5 994< 995]=] , 996fast =true , 997name ='byteidx' , 998params ={ { 'expr' , 'any' } , { 'nr' , 'integer' } , { 'utf16' , 'any' } } , 999returns ='integer' , 1000signature ='byteidx({expr}, {nr} [, {utf16}])' , 1001see_lua ={ 1002'|vim.str_byteindex()| for string input with `"utf-32"` or `"utf-16"` and `strict_indexing = false`; composing characters and out-of-range semantics differ' , 1003} , 1004} , 1005byteidxcomp ={ 1006args ={ 2 , 3 } , 1007base =1 , 1008desc =[=[ 1009Like |byteidx()|, except that a composing character is counted 1010as a separate character. Example: >vim 1011let s = 'e' .. nr2char(0x301) 1012echo byteidx(s, 1) 1013echo byteidxcomp(s, 1) 1014echo byteidxcomp(s, 2) 1015<The first and third echo result in 3 ('e' plus composing 1016character is 3 bytes), the second echo results in 1 ('e' is 1017one byte). 1018 1019]=] , 1020fast =true , 1021name ='byteidxcomp' , 1022params ={ { 'expr' , 'any' } , { 'nr' , 'integer' } , { 'utf16' , 'any' } } , 1023returns ='integer' , 1024signature ='byteidxcomp({expr}, {nr} [, {utf16}])' , 1025see_lua ={ 1026'|vim.str_byteindex()| with `"utf-32"` or `"utf-16"` and `strict_indexing = false`' , 1027} , 1028} , 1029call ={ 1030args ={ 2 , 3 } , 1031base =1 , 1032desc =[=[ 1033Call function {func} with the items in |List| {arglist} as 1034arguments. 1035{func} can either be a |Funcref| or the name of a function. 1036a:firstline and a:lastline are set to the cursor line. 1037Returns the return value of the called function. 1038{dict} is for functions with the "dict" attribute. It will be 1039used to set the local variable "self". |Dictionary-function| 1040 1041]=] , 1042name ='call' , 1043params ={ { 'func' , 'any' } , { 'arglist' , 'any' } , { 'dict' , 'any' } } , 1044returns ='any' , 1045signature ='call({func}, {arglist} [, {dict}])' , 1046tags ={ 'E699' } , 1047see_lua =false , 1048} , 1049ceil ={ 1050args =1 , 1051base =1 , 1052desc =[=[ 1053Return the smallest integral value greater than or equal to 1054{expr} as a |Float| (round up). 1055{expr} must evaluate to a |Float| or a |Number|. 1056Examples: >vim 1057echo ceil(1.456) 1058< 2.0 >vim 1059echo ceil(-5.456) 1060< -5.0 >vim 1061echo ceil(4.0) 1062< 4.0 1063 1064Returns 0.0 if {expr} is not a |Float| or a |Number|. 1065 1066]=] , 1067func_float ='ceil' , 1068name ='ceil' , 1069params ={ { 'expr' , 'number' } } , 1070returns ='number' , 1071signature ='ceil({expr})' , 1072see_lua ={ '|math.ceil()|' } , 1073} , 1074chanclose ={ 1075args ={ 1 , 2 } , 1076desc =[=[ 1077Close a channel or a specific stream associated with it. 1078For a job, {stream} can be one of "stdin", "stdout", 1079"stderr" or "rpc" (closes stdin/stdout for a job started 1080with `"rpc":v:true`) If {stream} is omitted, all streams 1081are closed. If the channel is a pty, this will then close the 1082pty master, sending SIGHUP to the job process. 1083For a socket, there is only one stream, and {stream} should be 1084omitted. 1085]=] , 1086name ='chanclose' , 1087params ={ { 'id' , 'integer' } , { 'stream' , 'string' } } , 1088returns ='0|1' , 1089signature ='chanclose({id} [, {stream}])' , 1090} , 1091changenr ={ 1092desc =[=[ 1093Return the number of the most recent change. This is the same 1094number as what is displayed with |:undolist| and can be used 1095with the |:undo| command. 1096When a change was made it is the number of that change. After 1097redo it is the number of the redone change. After undo it is 1098one less than the number of the undone change. 1099Returns 0 if the undo list is empty. 1100]=] , 1101name ='changenr' , 1102params ={} , 1103returns ='integer' , 1104signature ='changenr()' , 1105} , 1106chansend ={ 1107args =2 , 1108desc =[=[ 1109Send data to channel {id}. For a job, it writes it to the 1110stdin of the process. For the stdio channel |channel-stdio|, 1111it writes to Nvim's stdout. Returns the number of bytes 1112written if the write succeeded, 0 otherwise. 1113See |channel-bytes| for more information. 1114 1115{data} may be a string, string convertible, |Blob|, or a list. 1116 1117If {data} is a list, the items will be joined by newlines; any 1118newlines in an item will be sent as NUL; to send a final 1119newline, include a final empty string. |NL-used-for-Nul| 1120 1121Example: >vim 1122call chansend(id, ["abc", "123\n456", ""]) 1123<will send "abc<NL>123<NUL>456<NL>". 1124 1125chansend() writes raw data, not RPC messages. If the channel 1126was created with `"rpc":v:true` then the channel expects RPC 1127messages, use |rpcnotify()| and |rpcrequest()| instead. 1128]=] , 1129name ='chansend' , 1130params ={ { 'id' , 'number' } , { 'data' , 'string|string[]' } } , 1131returns ='integer' , 1132signature ='chansend({id}, {data})' , 1133see_lua ={ '|nvim_chan_send()| for string (binary) data' } , 1134} , 1135char2nr ={ 1136args ={ 1 , 2 } , 1137base =1 , 1138desc =[=[ 1139Return Number value of the first char in {string}. 1140Examples: >vim 1141echo char2nr(" ") " returns 32 1142echo char2nr("ABC") " returns 65 1143echo char2nr("á") " returns 225 1144echo char2nr("á"[0]) " returns 195 1145echo char2nr("\<M-x>") " returns 128 1146<Non-ASCII characters are always treated as UTF-8 characters. 1147{utf8} is ignored, it exists only for backwards-compatibility. 1148A combining character is a separate character. 1149|nr2char()| does the opposite. 1150 1151Returns 0 if {string} is not a |String|. 1152 1153]=] , 1154fast =true , 1155name ='char2nr' , 1156params ={ { 'string' , 'string' } , { 'utf8' , 'any' } } , 1157returns ='0|1' , 1158signature ='char2nr({string} [, {utf8}])' , 1159see_lua ={ '|string.byte()|: only works with ASCII' } , 1160} , 1161charclass ={ 1162args =1 , 1163base =1 , 1164desc =[=[ 1165Return the character class of the first character in {string}. 1166The character class is one of: 11670 blank 11681 punctuation 11692 word character (depends on 'iskeyword') 11703 emoji 1171other specific Unicode class 1172The class is used in patterns and word motions. 1173Returns 0 if {string} is not a |String|. 1174]=] , 1175name ='charclass' , 1176params ={ { 'string' , 'string' } } , 1177returns ="0|1|2|3|'other'" , 1178signature ='charclass({string})' , 1179} , 1180charcol ={ 1181args ={ 1 , 2 } , 1182base =1 , 1183desc =[=[ 1184Same as |col()| but returns the character index of the column 1185position given with {expr} instead of the byte position. 1186 1187Example: 1188With the cursor on '세' in line 5 with text "여보세요": >vim 1189echo charcol('.') " returns 3 1190echo col('.') " returns 7 1191< 1192 1193]=] , 1194name ='charcol' , 1195params ={ { 'expr' , 'string|any[]' } , { 'winid' , 'integer' } } , 1196returns ='integer' , 1197signature ='charcol({expr} [, {winid}])' , 1198see_lua ={ 1199'|nvim_win_get_cursor()| with |vim.str_utfindex()| for ".", or |nvim_get_current_line()| with |vim.str_utfindex()| for "$"; marks, list input, and window semantics differ' , 1200} , 1201} , 1202charidx ={ 1203args ={ 2 , 4 } , 1204base =1 , 1205desc =[=[ 1206Return the character index of the byte at {idx} in {string}. 1207The index of the first character is zero. 1208If there are no multibyte characters the returned value is 1209equal to {idx}. 1210 1211When {countcc} is omitted or |FALSE|, then composing characters 1212are not counted separately, their byte length is added to the 1213preceding base character. 1214When {countcc} is |TRUE|, then composing characters are 1215counted as separate characters. 1216 1217When {utf16} is present and TRUE, {idx} is used as the UTF-16 1218index in the String {expr} instead of as the byte index. 1219 1220Returns -1 if the arguments are invalid or if there are less 1221than {idx} bytes. If there are exactly {idx} bytes the length 1222of the string in characters is returned. 1223 1224An error is given and -1 is returned if the first argument is 1225not a string, the second argument is not a number or when the 1226third argument is present and is not zero or one. 1227 1228See |byteidx()| and |byteidxcomp()| for getting the byte index 1229from the character index and |utf16idx()| for getting the 1230UTF-16 index from the character index. 1231Refer to |string-offset-encoding| for more information. 1232Examples: >vim 1233echo charidx('áb́ć', 3) " returns 1 1234echo charidx('áb́ć', 6, 1) " returns 4 1235echo charidx('áb́ć', 16) " returns -1 1236echo charidx('a😊😊', 4, 0, 1) " returns 2 1237< 1238]=] , 1239fast =true , 1240name ='charidx' , 1241params ={ 1242{ 'string' , 'string' } , 1243{ 'idx' , 'integer' } , 1244{ 'countcc' , 'boolean' } , 1245{ 'utf16' , 'boolean' } , 1246} , 1247returns ='integer' , 1248signature ='charidx({string}, {idx} [, {countcc} [, {utf16}]])' , 1249see_lua ={ 1250'|vim.str_utfindex()| for string input with `"utf-32"` or `"utf-16"` and `strict_indexing = false`; `countcc = false` and out-of-range semantics differ' , 1251} , 1252} , 1253chdir ={ 1254args ={ 1 , 2 } , 1255base =1 , 1256desc =[=[ 1257Sets the |current-directory| of the given {scope}: 1258- "buffer" Changes the buffer-local directory. |:bcd| 1259- "window" Changes the window-local directory. |:lcd| 1260- "tabpage" Changes the tabpage-local directory. |:tcd| 1261- "global" Changes the global directory. |:cd| 1262 1263If {scope} is not given it is decided as follows: 1264- If buffer-local directory (|:bcd|) is set, scope is 1265"buffer". 1266- If the window-local directory (|:lcd|) is set, scope is 1267"window". 1268- If the tabpage-local directory (|:tcd|) is set, scope is 1269"tabpage". 1270- Otherwise, scope is "global". 1271 1272If successful, returns the previous working directory. 1273On failure, returns an empty string. 1274 1275Example: >vim 1276let save_dir = chdir(newdir) 1277if save_dir != "" 1278" ... do some work 1279call chdir(save_dir) 1280endif 1281< 1282 1283]=] , 1284name ='chdir' , 1285params ={ { 'dir' , 'string' } , { 'scope' , 'string' } } , 1286returns ='string' , 1287signature ='chdir({dir} [, {scope}])' , 1288} , 1289cindent ={ 1290args =1 , 1291base =1 , 1292desc =[=[ 1293Get the amount of indent for line {lnum} according the 1294|C-indenting| rules, as with 'cindent'. 1295The indent is counted in spaces, the value of 'tabstop' is 1296relevant. {lnum} is used just like in |getline()|. 1297When {lnum} is invalid -1 is returned. 1298 1299To get or set indent of lines in a string, see |vim.text.indent()|. 1300 1301]=] , 1302name ='cindent' , 1303params ={ { 'lnum' , 'integer|string' } } , 1304returns ='integer' , 1305signature ='cindent({lnum})' , 1306see_lua =false , 1307} , 1308clearmatches ={ 1309args ={ 0 , 1 } , 1310base =1 , 1311desc =[=[ 1312Clears all matches previously defined for the current window 1313by |matchadd()| and the |:match| commands. 1314If {win} is specified, use this |window-number| or |window-ID| 1315instead of the current window. 1316 1317]=] , 1318name ='clearmatches' , 1319params ={ { 'win' , 'integer' } } , 1320returns =false , 1321signature ='clearmatches([{win}])' , 1322} , 1323cmdcomplete_info ={ 1324args =0 , 1325desc =[=[ 1326Returns a |Dictionary| with information about cmdline 1327completion. See |cmdline-completion|. 1328The items are: 1329cmdline_orig The original command-line string before 1330completion began. 1331pum_visible |TRUE| if popup menu is visible. 1332See |pumvisible()|. 1333matches List of all completion candidates. Each item 1334is a string. 1335selected Selected item index. First index is zero. 1336Index is -1 if no item is selected (showing 1337typed text only, or the last completion after 1338no item is selected when using the <Up> or 1339<Down> keys) 1340 1341Returns an empty |Dictionary| if no completion was attempted, 1342if there was only one candidate and it was fully completed, or 1343if an error occurred. 1344]=] , 1345name ='cmdcomplete_info' , 1346params ={} , 1347returns ='table<string,any>' , 1348signature ='cmdcomplete_info()' , 1349} , 1350col ={ 1351args ={ 1 , 2 } , 1352base =1 , 1353desc =[=[ 1354Returns the byte index of the column position given with 1355{expr}. 1356For accepted positions see |getpos()|. 1357When {expr} is "$", it means the end of the cursor line, so 1358the result is the number of bytes in the cursor line plus one. 1359Additionally {expr} can be [lnum, col]: a |List| with the line 1360and column number. Most useful when the column is "$", to get 1361the last column of a specific line. When "lnum" or "col" is 1362out of range then col() returns zero. 1363 1364With the optional {winid} argument the values are obtained for 1365that window instead of the current window. 1366 1367To get the line number use |line()|. To get both use 1368|getpos()|. 1369 1370For the screen column position use |virtcol()|. For the 1371character position use |charcol()|. 1372 1373Note that only marks in the current file can be used. 1374 1375Examples: >vim 1376echo col(".") " column of cursor 1377echo col("$") " length of cursor line plus one 1378echo col("'t") " column of mark t 1379echo col("'" .. markname) " column of mark markname 1380< 1381The first column is 1. Returns 0 if {expr} is invalid or when 1382the window with ID {winid} is not found. 1383For an uppercase mark the column may actually be in another 1384buffer. 1385For the cursor position, when 'virtualedit' is active, the 1386column is one higher if the cursor is after the end of the 1387line. Also, when using a <Cmd> mapping the cursor isn't 1388moved, this can be used to obtain the column in Insert mode: >vim 1389imap <F2> <Cmd>echo col(".").."\n"<CR> 1390< 1391 1392]=] , 1393name ='col' , 1394params ={ { 'expr' , 'string|any[]' } , { 'winid' , 'integer' } } , 1395returns ='integer' , 1396signature ='col({expr} [, {winid}])' , 1397see_lua ={ 1398'|nvim_win_get_cursor()| for "." (add 1), or Lua `#` on |nvim_get_current_line()| for "$"; marks, list input, and `virtualedit` differ' , 1399} , 1400} , 1401complete ={ 1402args =2 , 1403base =2 , 1404desc =[=[ 1405Set the matches for Insert mode completion. Can only be used 1406in Insert mode. Typically invoked from a mapping with 1407CTRL-R = (see |i_CTRL-R|), but may also be called from a 1408|<Cmd>| mapping. It does not work after CTRL-O or with an 1409expression mapping. 1410{startcol} is the byte offset in the line where the completed 1411text start. The text up to the cursor is the original text 1412that will be replaced by the matches. Use col('.') for an 1413empty string. "col('.') - 1" will replace one character by a 1414match. 1415{matches} must be a |List|. Each |List| item is one match. 1416See |complete-items| for the kind of items that are possible. 1417"longest" in 'completeopt' is ignored. 1418Note that the after calling this function you need to avoid 1419inserting anything that would cause completion to stop. 1420The match can be selected with CTRL-N and CTRL-P as usual with 1421Insert mode completion. The popup menu will appear if 1422specified, see |ins-completion-menu|. 1423Unlike with other |ins-completion| modes, the CTRL-N and 1424CTRL-P keys can be mapped while this completion is active. 1425For example, to make CTRL-N move the selection without 1426inserting the match: >vim 1427 1428inoremap <expr> <C-N> complete_info().mode ==# 'eval' 1429\ ? '<Down>' : '<C-N>' 1430< 1431 1432Example: >vim 1433 1434inoremap <F5> <C-R>=ListMonths()<CR> 1435 1436func ListMonths() 1437call complete(col('.'), ['January', 'February', 'March', 1438\ 'April', 'May', 'June', 'July', 'August', 1439\ 'September', 'October', 'November', 'December']) 1440return '' 1441endfunc 1442 1443<This isn't very useful, but it shows how it works. Note that 1444an empty string is returned to avoid a zero being inserted. 1445 1446]=] , 1447name ='complete' , 1448params ={ { 'startcol' , 'integer' } , { 'matches' , 'any[]' } } , 1449returns =false , 1450signature ='complete({startcol}, {matches})' , 1451tags ={ 'E785' } , 1452} , 1453complete_add ={ 1454args =1 , 1455base =1 , 1456desc =[=[ 1457Add {expr} to the list of matches. Only to be used by the 1458function specified with the 'completefunc' option. 1459Returns 0 for failure (empty string or out of memory), 14601 when the match was added, 2 when the match was already in 1461the list. 1462See |complete-functions| for an explanation of {expr}. It is 1463the same as one item in the list that 'omnifunc' would return. 1464 1465]=] , 1466name ='complete_add' , 1467params ={ { 'expr' , 'any' } } , 1468returns ='0|1|2' , 1469signature ='complete_add({expr})' , 1470} , 1471complete_check ={ 1472desc =[=[ 1473Check for a key typed while looking for completion matches. 1474This is to be used when looking for matches takes some time. 1475Returns |TRUE| when searching for matches is to be aborted, 1476zero otherwise. 1477Only to be used by the function specified with the 1478'completefunc' option. 1479]=] , 1480name ='complete_check' , 1481params ={} , 1482returns ='0|1' , 1483signature ='complete_check()' , 1484} , 1485complete_info ={ 1486args ={ 0 , 1 } , 1487base =1 , 1488desc =[=[ 1489Returns a |Dictionary| with information about Insert mode 1490completion. See |ins-completion|. 1491The items are: 1492auto |TRUE| when Vim started this completion by 1493itself, which is what 'autocomplete' does, 1494and |FALSE| when a key asked for it, such as 1495|i_CTRL-X_CTRL-O|. A |complete-functions| 1496function can read this to tell the two apart. 1497Returned only when asked for in {what}. 1498completed Return a dictionary containing the entries of 1499the currently selected index item. 1500items List of all completion candidates. Each item 1501is a dictionary containing the entries "word", 1502"abbr", "menu", "kind", "info", 1503"abbr_hlgroup", "kind_hlgroup" and 1504"user_data". The highlight group entries hold 1505the name that the item was added with, 1506or an empty string. 1507"equal", "preselect" and "commit_chars" are 1508included only for items that set them. 1509See |complete-items|. 1510matches Same as "items", but only returns items that 1511are matching current query. If both "matches" 1512and "items" are in "what", the returned list 1513will still be named "items", but each item 1514will have an additional "match" field. 1515mode Current completion mode name string. 1516See |complete_info_mode| for the values. 1517preinserted_text 1518The actual text that is pre-inserted, see 1519|preinserted()|. 1520pum_visible |TRUE| if popup menu is visible. 1521See |pumvisible()|. 1522selected Selected item index. First index is zero. 1523Index is -1 if no item is selected (showing 1524typed text only, or the last completion after 1525no item is selected when using the <Up> or 1526<Down> keys) 1527preview_winid Info floating preview window id. 1528preview_bufnr Info floating preview buffer id. 1529 1530*complete_info_mode* 1531mode values are: 1532"" Not in completion mode 1533"keyword" Keyword completion |i_CTRL-X_CTRL-N| 1534"ctrl_x" Just pressed CTRL-X |i_CTRL-X| 1535"scroll" Scrolling with |i_CTRL-X_CTRL-E| or 1536|i_CTRL-X_CTRL-Y| 1537"whole_line" Whole lines |i_CTRL-X_CTRL-L| 1538"files" File names |i_CTRL-X_CTRL-F| 1539"tags" Tags |i_CTRL-X_CTRL-]| 1540"path_defines" Definition completion |i_CTRL-X_CTRL-D| 1541"path_patterns" Include completion |i_CTRL-X_CTRL-I| 1542"dictionary" Dictionary |i_CTRL-X_CTRL-K| 1543"thesaurus" Thesaurus |i_CTRL-X_CTRL-T| 1544"cmdline" Vim Command line |i_CTRL-X_CTRL-V| 1545"function" User defined completion |i_CTRL-X_CTRL-U| 1546"omni" Omni completion |i_CTRL-X_CTRL-O| 1547"spell" Spelling suggestions |i_CTRL-X_s| 1548"eval" |complete()| completion 1549"register" Words from registers |i_CTRL-X_CTRL-R| 1550"unknown" Other internal modes 1551 1552If the optional {what} list argument is supplied, then only 1553the items listed in {what} are returned. Unsupported items in 1554{what} are silently ignored. 1555 1556To get the position and size of the popup menu, see 1557|pum_getpos()|. It's also available in |v:event| during the 1558|CompleteChanged| event. 1559 1560Returns an empty |Dictionary| on error. 1561 1562Examples: >vim 1563" Get all items 1564call complete_info() 1565" Get only 'mode' 1566call complete_info(['mode']) 1567" Get only 'mode' and 'pum_visible' 1568call complete_info(['mode', 'pum_visible']) 1569< 1570 1571]=] , 1572name ='complete_info' , 1573params ={ { 'what' , 'any[]' } } , 1574returns ='table' , 1575signature ='complete_info([{what}])' , 1576} , 1577confirm ={ 1578args ={ 1 , 4 } , 1579base =1 , 1580desc =[=[ 1581confirm() offers the user a dialog, from which a choice can be 1582made. It returns the number of the choice. For the first 1583choice this is 1. 1584 1585{msg} is displayed in a dialog with {choices} as the 1586alternatives. When {choices} is missing or empty, "&OK" is 1587used (and translated). 1588{msg} is a String, use '\n' to include a newline. Only on 1589some systems the string is wrapped when it doesn't fit. 1590 1591{choices} is a String, with the individual choices separated 1592by '\n', e.g. >vim 1593confirm("Save changes?", "&Yes\n&No\n&Cancel") 1594<The letter after the '&' is the shortcut key for that choice. 1595Thus you can type 'c' to select "Cancel". The shortcut does 1596not need to be the first letter: >vim 1597confirm("file has been modified", "&Save\nSave &All") 1598<For the console, the first letter of each choice is used as 1599the default shortcut key. Case is ignored. 1600 1601The optional {type} String argument gives the type of dialog. 1602It can be one of these values: "Error", "Question", "Info", 1603"Warning" or "Generic". Only the first character is relevant. 1604When {type} is omitted, "Generic" is used. 1605 1606The optional {type} argument gives the type of dialog. This 1607is only used for the icon of the Win32 GUI. It can be one of 1608these values: "Error", "Question", "Info", "Warning" or 1609"Generic". Only the first character is relevant. 1610When {type} is omitted, "Generic" is used. 1611 1612If the user aborts the dialog by pressing <Esc>, CTRL-C, 1613or another valid interrupt key, confirm() returns 0. 1614 1615An example: >vim 1616let choice = confirm("What do you want?", 1617\ "&Apples\n&Oranges\n&Bananas", 2) 1618if choice == 0 1619echo "make up your mind!" 1620elseif choice == 3 1621echo "tasteful" 1622else 1623echo "I prefer bananas myself." 1624endif 1625<In a GUI dialog, buttons are used. The layout of the buttons 1626depends on the 'v' flag in 'guioptions'. If it is included, 1627the buttons are always put vertically. Otherwise, confirm() 1628tries to put the buttons in one horizontal line. If they 1629don't fit, a vertical layout is used anyway. For some systems 1630the horizontal layout is always used. 1631 1632]=] , 1633name ='confirm' , 1634params ={ 1635{ 'msg' , 'string' } , 1636{ 'choices' , 'string' } , 1637{ 'default' , 'integer' } , 1638{ 'type' , 'string' } , 1639} , 1640returns ='integer' , 1641signature ='confirm({msg} [, {choices} [, {default} [, {type}]]])' , 1642} , 1643copy ={ 1644args =1 , 1645base =1 , 1646desc =[=[ 1647Make a copy of {expr}. For Numbers and Strings this isn't 1648different from using {expr} directly. 1649When {expr} is a |List| a shallow copy is created. This means 1650that the original |List| can be changed without changing the 1651copy, and vice versa. But the items are identical, thus 1652changing an item changes the contents of both |Lists|. 1653A |Dictionary| is copied in a similar way as a |List|. 1654Also see |deepcopy()|. 1655]=] , 1656generics ={ 'T' } , 1657name ='copy' , 1658params ={ { 'expr' , 'T' } } , 1659returns ='T' , 1660signature ='copy({expr})' , 1661see_lua ={ '|vim.deepcopy()|; deeper than Vimscript |copy()|' } , 1662} , 1663cos ={ 1664args =1 , 1665base =1 , 1666desc =[=[ 1667Return the cosine of {expr}, measured in radians, as a |Float|. 1668{expr} must evaluate to a |Float| or a |Number|. 1669Returns 0.0 if {expr} is not a |Float| or a |Number|. 1670Examples: >vim 1671echo cos(100) 1672< 0.862319 >vim 1673echo cos(-4.01) 1674< -0.646043 1675 1676]=] , 1677func_float ='cos' , 1678name ='cos' , 1679params ={ { 'expr' , 'number' } } , 1680returns ='number' , 1681signature ='cos({expr})' , 1682see_lua ={ '|math.cos()|' } , 1683} , 1684cosh ={ 1685args =1 , 1686base =1 , 1687desc =[=[ 1688Return the hyperbolic cosine of {expr} as a |Float| in the range 1689[1, inf]. 1690{expr} must evaluate to a |Float| or a |Number|. 1691Returns 0.0 if {expr} is not a |Float| or a |Number|. 1692Examples: >vim 1693echo cosh(0.5) 1694< 1.127626 >vim 1695echo cosh(-0.5) 1696< 1.127626 1697 1698]=] , 1699func_float ='cosh' , 1700name ='cosh' , 1701params ={ { 'expr' , 'number' } } , 1702returns ='number' , 1703signature ='cosh({expr})' , 1704see_lua ={ '|math.cosh()|' } , 1705} , 1706count ={ 1707args ={ 2 , 4 } , 1708base =1 , 1709tags ={ 'E706' } , 1710desc =[=[ 1711Return the number of times an item with value {expr} appears 1712in |String|, |List| or |Dictionary| {comp}. 1713 1714If {start} is given then start with the item with this index. 1715{start} can only be used with a |List|. 1716 1717When {ic} is given and it's |TRUE| then case is ignored. 1718 1719When {comp} is a string then the number of not overlapping 1720occurrences of {expr} is returned. Zero is returned when 1721{expr} is an empty string. 1722 1723]=] , 1724name ='count' , 1725params ={ 1726{ 'comp' , 'string|table|any[]' } , 1727{ 'expr' , 'any' } , 1728{ 'ic' , 'boolean' } , 1729{ 'start' , 'integer' } , 1730} , 1731returns ='integer' , 1732signature ='count({comp}, {expr} [, {ic} [, {start}]])' , 1733} , 1734cursor ={ 1735args ={ 1 , 3 } , 1736base =1 , 1737name ='cursor' , 1738params ={ { 'lnum' , 'integer|string' } , { 'col' , 'integer' } , { 'off' , 'integer' } } , 1739signature ='cursor({lnum}, {col} [, {off}])' , 1740see_lua =false , -- see cursor__1 1741} , 1742cursor__1 ={ 1743args ={ 1 , 3 } , 1744base =1 , 1745desc =[=[ 1746Positions the cursor at the column (byte count) {col} in the 1747line {lnum}. The first column is one. 1748 1749When there is one argument {list} this is used as a |List| 1750with two, three or four item: 1751[{lnum}, {col}] 1752[{lnum}, {col}, {off}] 1753[{lnum}, {col}, {off}, {curswant}] 1754This is like the return value of |getpos()| or |getcurpos()|, 1755but without the first item. 1756 1757To position the cursor using {col} as the character count, use 1758|setcursorcharpos()|. 1759 1760Does not change the jumplist. 1761{lnum} is used like with |getline()|, except that if {lnum} is 1762zero, the cursor will stay in the current line. 1763If {lnum} is greater than the number of lines in the buffer, 1764the cursor will be positioned at the last line in the buffer. 1765If {col} is greater than the number of bytes in the line, 1766the cursor will be positioned at the last character in the 1767line. 1768If {col} is zero, the cursor will stay in the current column. 1769If {curswant} is given it is used to set the preferred column 1770for vertical movement. Otherwise {col} is used. 1771 1772When 'virtualedit' is used {off} specifies the offset in 1773screen columns from the start of the character. E.g., a 1774position within a <Tab> or after the last character. 1775Returns 0 when the position could be set, -1 otherwise. 1776 1777]=] , 1778name ='cursor' , 1779params ={ { 'list' , 'integer[]' } } , 1780signature ='cursor({list})' , 1781see_lua ={ 1782'|nvim_win_set_cursor()| with `{lnum, col - 1}`; `off`, `curswant`, and failure semantics differ' , 1783} , 1784} , 1785debugbreak ={ 1786args ={ 1 , 1 } , 1787base =1 , 1788desc =[=[ 1789Specifically used to interrupt a program being debugged. It 1790will cause process {pid} to get a SIGTRAP. Behavior for other 1791processes is undefined. See |terminal-debug|. 1792(Sends a SIGINT to a process {pid} other than MS-Windows) 1793 1794Returns |TRUE| if successfully interrupted the program. 1795Otherwise returns |FALSE|. 1796 1797]=] , 1798name ='debugbreak' , 1799params ={ { 'pid' , 'integer' } } , 1800signature ='debugbreak({pid})' , 1801see_lua ={ 1802'|uv.kill()| with `"sigtrap"` (or `"sigint"` outside MS-Windows); exact semantics differ' , 1803} , 1804} , 1805deepcopy ={ 1806args ={ 1 , 2 } , 1807base =1 , 1808tags ={ 'E698' } , 1809desc =[=[ 1810Make a copy of {expr}. For Numbers and Strings this isn't 1811different from using {expr} directly. 1812When {expr} is a |List| a full copy is created. This means 1813that the original |List| can be changed without changing the 1814copy, and vice versa. When an item is a |List|, a copy for it 1815is made, recursively. Thus changing an item in the copy does 1816not change the contents of the original |List|. 1817 1818When {noref} is omitted or zero a contained |List| or 1819|Dictionary| is only copied once. All references point to 1820this single copy. With {noref} set to 1 every occurrence of a 1821|List| or |Dictionary| results in a new copy. This also means 1822that a cyclic reference causes deepcopy() to fail. 1823*E724* 1824Nesting is possible up to 100 levels. When there is an item 1825that refers back to a higher level making a deep copy with 1826{noref} set to 1 will fail. 1827Also see |copy()|. 1828 1829]=] , 1830generics ={ 'T' } , 1831name ='deepcopy' , 1832params ={ { 'expr' , 'T' } , { 'noref' , 'boolean' } } , 1833returns ='T' , 1834signature ='deepcopy({expr} [, {noref}])' , 1835see_lua ={ '|vim.deepcopy()|' } , 1836} , 1837delete ={ 1838args ={ 1 , 2 } , 1839base =1 , 1840desc =[=[ 1841Without {flags} or with {flags} empty: Deletes the file by the 1842name {fname}. 1843 1844This also works when {fname} is a symbolic link. The symbolic 1845link itself is deleted, not what it points to. 1846 1847When {flags} is "d": Deletes the directory by the name 1848{fname}. This fails when directory {fname} is not empty. 1849 1850When {flags} is "rf": Deletes the directory by the name 1851{fname} and everything in it, recursively. BE CAREFUL! 1852Note: on MS-Windows it is not possible to delete a directory 1853that is being used. 1854 1855The result is a Number, which is 0/false if the delete 1856operation was successful and -1/true when the deletion failed 1857or partly failed. 1858 1859]=] , 1860name ='delete' , 1861params ={ { 'fname' , 'string' } , { 'flags' , 'string' } } , 1862returns ='integer' , 1863signature ='delete({fname} [, {flags}])' , 1864see_lua ={ '|vim.fs.rm()|' } , 1865} , 1866deletebufline ={ 1867args ={ 2 , 3 } , 1868base =1 , 1869desc =[=[ 1870Delete lines {first} to {last} (inclusive) from buffer {buf}. 1871If {last} is omitted then delete line {first} only. 1872On success 0 is returned, on failure 1 is returned. 1873 1874This function works only for loaded buffers. First call 1875|bufload()| if needed. 1876 1877For the use of {buf}, see |bufname()| above. 1878 1879{first} and {last} are used like with |getline()|. Note that 1880when using |line()| this refers to the current buffer. Use "$" 1881to refer to the last line in buffer {buf}. 1882 1883]=] , 1884name ='deletebufline' , 1885params ={ 1886{ 'buf' , 'integer|string' } , 1887{ 'first' , 'integer|string' } , 1888{ 'last' , 'integer|string' } , 1889} , 1890signature ='deletebufline({buf}, {first} [, {last}])' , 1891see_lua ={ '|nvim_buf_set_lines()|' } , 1892} , 1893dictwatcheradd ={ 1894args =3 , 1895desc =[=[ 1896Adds a watcher to a dictionary. A dictionary watcher is 1897identified by three components: 1898 1899- A dictionary({dict}); 1900- A key pattern({pattern}). 1901- A function({callback}). 1902 1903After this is called, every change on {dict} and on keys 1904matching {pattern} will result in {callback} being invoked. 1905 1906For example, to watch all global variables: >vim 1907silent! call dictwatcherdel(g:, '*', 'OnDictChanged') 1908function! OnDictChanged(d,k,z) 1909echomsg string(a:k) string(a:z) 1910endfunction 1911call dictwatcheradd(g:, '*', 'OnDictChanged') 1912< 1913For now {pattern} only accepts very simple patterns that can 1914contain a "*" at the end of the string, in which case it will 1915match every key that begins with the substring before the "*". 1916That means if "*" is not the last character of {pattern}, only 1917keys that are exactly equal as {pattern} will be matched. 1918 1919The {callback} receives three arguments: 1920 1921- The dictionary being watched. 1922- The key which changed. 1923- A dictionary containing the new and old values for the key. 1924 1925The type of change can be determined by examining the keys 1926present on the third argument: 1927 1928- If contains both `old` and `new`, the key was updated. 1929- If it contains only `new`, the key was added. 1930- If it contains only `old`, the key was deleted. 1931 1932This function can be used by plugins to implement options with 1933validation and parsing logic. 1934]=] , 1935name ='dictwatcheradd' , 1936params ={ { 'dict' , 'table' } , { 'pattern' , 'string' } , { 'callback' , 'function' } } , 1937signature ='dictwatcheradd({dict}, {pattern}, {callback})' , 1938see_lua =false , 1939} , 1940dictwatcherdel ={ 1941args =3 , 1942desc =[=[ 1943Removes a watcher added with |dictwatcheradd()|. All three 1944arguments must match the ones passed to |dictwatcheradd()| in 1945order for the watcher to be successfully deleted. 1946]=] , 1947name ='dictwatcherdel' , 1948params ={ { 'dict' , 'any' } , { 'pattern' , 'string' } , { 'callback' , 'function' } } , 1949signature ='dictwatcherdel({dict}, {pattern}, {callback})' , 1950see_lua =false , 1951} , 1952did_filetype ={ 1953desc =[=[ 1954Returns |TRUE| when autocommands are being executed and the 1955FileType event triggered at least once for a buffer with 1956a non-empty 'filetype'. Can be used to avoid triggering 1957the FileType event again in the |ftdetect| scripts. |FileType| 1958Returns |FALSE| when `:setf FALLBACK` was used. 1959 1960When editing another file, the counter is reset, thus this 1961really checks if the FileType event has been triggered for the 1962current buffer. This allows an autocommand that starts 1963editing another buffer to set 'filetype' and load a syntax 1964file. 1965]=] , 1966fast =true , 1967name ='did_filetype' , 1968params ={} , 1969returns ='integer' , 1970signature ='did_filetype()' , 1971} , 1972diff_filler ={ 1973args =1 , 1974base =1 , 1975desc =[=[ 1976Returns the number of filler lines above line {lnum}. 1977These are the lines that were inserted at this point in 1978another diff'ed window. These filler lines are shown in the 1979display but don't exist in the buffer. 1980{lnum} is used like with |getline()|. Thus "." is the current 1981line, "'m" mark m, etc. 1982 1983To get the filler lines after the last buffer line, use: >vim 1984echo diff_filler(line('$')+1) 1985< 1986Returns 0 if the current window is not in diff mode or filler 1987lines have been disabled using 'diffopt'. 1988]=] , 1989name ='diff_filler' , 1990params ={ { 'lnum' , 'integer|string' } } , 1991returns ='integer' , 1992signature ='diff_filler({lnum})' , 1993} , 1994diff_hlID ={ 1995args =2 , 1996base =1 , 1997desc =[=[ 1998Returns the highlight ID for diff mode at line {lnum} column 1999{col} (byte index). When the current line does not have a 2000diff change zero is returned. 2001{lnum} is used like with |getline()|. Thus "." is the current 2002line, "'m" mark m, etc. 2003{col} is 1 for the leftmost column, {lnum} is 1 for the first 2004line. 2005The highlight ID can be used with |synIDattr()| to obtain 2006syntax information about the highlighting. 2007 2008]=] , 2009name ='diff_hlID' , 2010params ={ { 'lnum' , 'integer|string' } , { 'col' , 'integer' } } , 2011signature ='diff_hlID({lnum}, {col})' , 2012} , 2013digraph_get ={ 2014args =1 , 2015base =1 , 2016tags ={ 'E1214' } , 2017desc =[=[ 2018Return the digraph of {chars}. This should be a string with 2019exactly two characters. If {chars} are not just two 2020characters, or the digraph of {chars} does not exist, an error 2021is given and an empty string is returned. 2022 2023Also see |digraph_getlist()|. 2024 2025Examples: >vim 2026" Get a built-in digraph 2027echo digraph_get('00') " Returns '∞' 2028 2029" Get a user-defined digraph 2030call digraph_set('aa', 'あ') 2031echo digraph_get('aa') " Returns 'あ' 2032< 2033]=] , 2034name ='digraph_get' , 2035params ={ { 'chars' , 'string' } } , 2036returns ='string' , 2037signature ='digraph_get({chars})' , 2038} , 2039digraph_getlist ={ 2040args ={ 0 , 1 } , 2041base =1 , 2042desc =[=[ 2043Return a list of digraphs. If the {listall} argument is given 2044and it is TRUE, return all digraphs, including the default 2045digraphs. Otherwise, return only user-defined digraphs. 2046 2047Also see |digraph_get()|. 2048 2049Examples: >vim 2050" Get user-defined digraphs 2051echo digraph_getlist() 2052 2053" Get all the digraphs, including default digraphs 2054echo digraph_getlist(1) 2055< 2056]=] , 2057name ='digraph_getlist' , 2058params ={ { 'listall' , 'boolean' } } , 2059returns ='string[][]' , 2060signature ='digraph_getlist([{listall}])' , 2061} , 2062digraph_set ={ 2063args =2 , 2064base =1 , 2065desc =[=[ 2066Add digraph {chars} to the list. {chars} must be a string 2067with two characters. {digraph} is a string with one UTF-8 2068encoded character. *E1215* 2069Be careful, composing characters are NOT ignored. This 2070function is similar to |:digraphs| command, but useful to add 2071digraphs start with a white space. 2072 2073The function result is v:true if |digraph| is registered. If 2074this fails an error message is given and v:false is returned. 2075 2076If you want to define multiple digraphs at once, you can use 2077|digraph_setlist()|. 2078 2079Example: >vim 2080call digraph_set(' ', 'あ') 2081< 2082]=] , 2083name ='digraph_set' , 2084params ={ { 'chars' , 'string' } , { 'digraph' , 'string' } } , 2085signature ='digraph_set({chars}, {digraph})' , 2086} , 2087digraph_setlist ={ 2088args =1 , 2089base =1 , 2090desc =[=[ 2091Similar to |digraph_set()| but this function can add multiple 2092digraphs at once. {digraphlist} is a list composed of lists, 2093where each list contains two strings with {chars} and 2094{digraph} as in |digraph_set()|. *E1216* 2095Example: >vim 2096call digraph_setlist([['aa', 'あ'], ['ii', 'い']]) 2097< 2098It is similar to the following: >vim 2099for [chars, digraph] in [['aa', 'あ'], ['ii', 'い']] 2100call digraph_set(chars, digraph) 2101endfor 2102<Except that the function returns after the first error, 2103following digraphs will not be added. 2104]=] , 2105name ='digraph_setlist' , 2106params ={ { 'digraphlist' , 'table<integer,string[]>' } } , 2107signature ='digraph_setlist({digraphlist})' , 2108} , 2109empty ={ 2110args =1 , 2111base =1 , 2112desc =[=[ 2113Return the Number 1 if {expr} is empty, zero otherwise. 2114- A |List| or |Dictionary| is empty when it does not have any 2115items. 2116- A |String| is empty when its length is zero. 2117- A |Number| and |Float| are empty when their value is zero. 2118- |v:false| and |v:null| are empty, |v:true| is not. 2119- A |Blob| is empty when its length is zero. 2120 2121]=] , 2122name ='empty' , 2123params ={ { 'expr' , 'any' } } , 2124returns ='integer' , 2125signature ='empty({expr})' , 2126see_lua ={ 'plain Lua emptiness checks, or |vim.tbl_isempty()| for tables' } , 2127} , 2128environ ={ 2129desc =[=[ 2130Return all of environment variables as dictionary. You can 2131check if an environment variable exists like this: >vim 2132echo has_key(environ(), 'HOME') 2133<Note that the variable name may be CamelCase; to ignore case 2134use this: >vim 2135echo index(keys(environ()), 'HOME', 0, 1) != -1 2136< 2137]=] , 2138fast =true , 2139func_lua ='f_environ' , 2140name ='environ' , 2141params ={} , 2142signature ='environ()' , 2143see_lua ={ '|uv.os_environ()| for the full environment table; |vim.env| for keyed access' } , 2144} , 2145escape ={ 2146args =2 , 2147base =1 , 2148desc =[=[ 2149Escape the characters in {chars} that occur in {string} with a 2150backslash. Example: >vim 2151echo escape('c:\program files\vim', ' \') 2152<results in: > 2153c:\\program\ files\\vim 2154<Also see |shellescape()| and |fnameescape()|. 2155 2156]=] , 2157fast =true , 2158name ='escape' , 2159params ={ { 'string' , 'string' } , { 'chars' , 'string' } } , 2160returns ='string' , 2161signature ='escape({string}, {chars})' , 2162} , 2163eval ={ 2164args =1 , 2165base =1 , 2166desc =[=[ 2167Evaluate {string} and return the result. Especially useful to 2168turn the result of |string()| back into the original value. 2169This works for Numbers, Floats, Strings, Blobs and composites 2170of them. Also works for |Funcref|s that refer to existing 2171functions. 2172 2173]=] , 2174name ='eval' , 2175params ={ { 'string' , 'string' } } , 2176signature ='eval({string})' , 2177see_lua =false , 2178} , 2179eventhandler ={ 2180desc =[=[ 2181Returns 1 when inside an event handler. That is that Vim got 2182interrupted while waiting for the user to type a character, 2183e.g., when dropping a file on Vim. This means interactive 2184commands cannot be used. Otherwise zero is returned. 2185]=] , 2186name ='eventhandler' , 2187params ={} , 2188signature ='eventhandler()' , 2189} , 2190executable ={ 2191args =1 , 2192base =1 , 2193desc =[=[ 2194This function checks if an executable with the name {expr} 2195exists. {expr} must be the name of the program without any 2196arguments. 2197 2198executable() uses the value of $PATH and/or the normal 2199searchpath for programs. 2200*PATHEXT* 2201On MS-Windows the ".exe", ".bat", etc. can optionally be 2202included. Then the extensions in $PATHEXT are tried. Thus if 2203"foo.exe" does not exist, "foo.exe.bat" can be found. If 2204$PATHEXT is not set then ".com;.exe;.bat;.cmd" is used. A dot 2205by itself can be used in $PATHEXT to try using the name 2206without an extension. When 'shell' looks like a Unix shell, 2207then the name is also tried without adding an extension. 2208On MS-Windows it only checks if the file exists and is not a 2209directory, not if it's really executable. 2210 2211On MS-Windows an executable in the same directory as the Vim 2212executable is always found (it's added to $PATH at |startup|). 2213*$NoDefaultCurrentDirectoryInExePath* 2214On MS-Windows when using cmd.exe as 'shell' an executable in 2215Vim's current working directory is also normally found, which 2216can be disabled by setting the 2217`$NoDefaultCurrentDirectoryInExePath` environment variable. 2218This variable is always set by Vim when executing external 2219commands (e.g., via |:!|, |:make|, or |system()|) for security 2220reasons. 2221 2222The result is a Number: 22231 exists 22240 does not exist 2225|exepath()| can be used to get the full path of an executable. 2226 2227]=] , 2228fast =true , 2229name ='executable' , 2230params ={ { 'expr' , 'string' } } , 2231returns ='0|1' , 2232signature ='executable({expr})' , 2233} , 2234execute ={ 2235args ={ 1 , 2 } , 2236base =1 , 2237desc =[=[ 2238Execute {command} and capture its output. 2239If {command} is a |String|, returns {command} output. 2240If {command} is a |List|, returns concatenated outputs. 2241Line continuations in {command} are not recognized. 2242Examples: >vim 2243echo execute('echon "foo"') 2244< foo >vim 2245echo execute(['echon "foo"', 'echon "bar"']) 2246< foobar 2247 2248The optional {silent} argument can have these values: 2249"" no `:silent` used 2250"silent" `:silent` used 2251"silent!" `:silent!` used 2252The default is "silent". Note that with "silent!", unlike 2253`:redir`, error messages are dropped. 2254 2255To get a list of lines use `split()` on the result: >vim 2256execute('args')->split("\n") 2257 2258<This function is not available in the |sandbox|. 2259Note: If nested, an outer execute() will not observe output of 2260the inner calls. 2261Note: Text attributes (highlights) are not captured. 2262To execute a command in another window than the current one 2263use `win_execute()`. 2264 2265]=] , 2266name ='execute' , 2267params ={ 2268{ 'command' , 'string|string[]' } , 2269{ 'silent' , "''|'silent'|'silent!'" } , 2270} , 2271returns ='string' , 2272signature ='execute({command} [, {silent}])' , 2273see_lua ={ '|nvim_exec()|' , '|vim.cmd()|' } , 2274} , 2275exepath ={ 2276args =1 , 2277base =1 , 2278desc =[=[ 2279Returns the full path of {expr} if it is an executable and 2280given as a (partial or full) path or is found in $PATH. 2281Returns empty string otherwise. 2282If {expr} starts with "./" the |current-directory| is used. 2283 2284]=] , 2285fast =true , 2286name ='exepath' , 2287params ={ { 'expr' , 'string' } } , 2288signature ='exepath({expr})' , 2289returns ='string' , 2290} , 2291exists ={ 2292args =1 , 2293base =1 , 2294desc =[=[ 2295Checks whether the expression {expr} is defined. 2296Returns |TRUE| if {expr} is defined, zero otherwise. 2297 2298For checking for a supported feature use |has()|. 2299For checking if a file exists use |filereadable()|. 2300 2301The {expr} argument is a string, which contains one of these: 2302varname internal variable (see 2303dict.key |internal-variables|). Also works 2304list[i] for |curly-braces-names|, |Dictionary| 2305entries, |List| items, etc. 2306Beware that evaluating an index may 2307cause an error message for an invalid 2308expression. E.g.: >vim 2309let l = [1, 2, 3] 2310echo exists("l[5]") 2311< 0 >vim 2312echo exists("l[xx]") 2313< E121: Undefined variable: xx 23140 2315&option-name Vim option (only checks if it exists, 2316not if it really works) 2317+option-name Vim option that works. 2318$ENVNAME environment variable (could also be 2319done by comparing with an empty 2320string) 2321`*funcname` built-in function (see |functions|) 2322or user defined function (see 2323|user-function|). Also works for a 2324variable that is a Funcref. 2325:cmdname Ex command: built-in command, user 2326command or command modifier |:command|. 2327Returns: 23281 for match with start of a command 23292 full match with a command 23303 matches several user commands 2331To check for a supported command 2332always check the return value to be 2. 2333:2match The |:2match| command. 2334:3match The |:3match| command (but you 2335probably should not use it, it is 2336reserved for internal usage) 2337#event autocommand defined for this event 2338#event#pattern autocommand defined for this event and 2339pattern (the pattern is taken 2340literally and compared to the 2341autocommand patterns character by 2342character) 2343#group autocommand group exists 2344#group#event autocommand defined for this group and 2345event. 2346#group#event#pattern 2347autocommand defined for this group, 2348event and pattern. 2349##event autocommand for this event is 2350supported. 2351 2352Examples: >vim 2353echo exists("&mouse") 2354echo exists("$HOSTNAME") 2355echo exists("*strftime") 2356echo exists("*s:MyFunc") 2357echo exists("*MyFunc") 2358echo exists("*v:lua.Func") 2359echo exists("bufcount") 2360echo exists(":Make") 2361echo exists("#CursorHold") 2362echo exists("#BufReadPre#*.gz") 2363echo exists("#filetypeindent") 2364echo exists("#filetypeindent#FileType") 2365echo exists("#filetypeindent#FileType#*") 2366echo exists("##ColorScheme") 2367<There must be no space between the symbol (&/$/*/#) and the 2368name. 2369There must be no extra characters after the name, although in 2370a few cases this is ignored. That may become stricter in the 2371future, thus don't count on it! 2372Working example: >vim 2373echo exists(":make") 2374<NOT working example: >vim 2375echo exists(":make install") 2376 2377<Note that the argument must be a string, not the name of the 2378variable itself. For example: >vim 2379echo exists(bufcount) 2380<This doesn't check for existence of the "bufcount" variable, 2381but gets the value of "bufcount", and checks if that exists. 2382 2383]=] , 2384name ='exists' , 2385params ={ { 'expr' , 'string' } } , 2386returns ='0|1' , 2387signature ='exists({expr})' , 2388} , 2389exp ={ 2390args =1 , 2391base =1 , 2392desc =[=[ 2393Return the exponential of {expr} as a |Float| in the range 2394[0, inf]. 2395{expr} must evaluate to a |Float| or a |Number|. 2396Returns 0.0 if {expr} is not a |Float| or a |Number|. 2397Examples: >vim 2398echo exp(2) 2399< 7.389056 >vim 2400echo exp(-1) 2401< 0.367879 2402 2403]=] , 2404func_float ='exp' , 2405name ='exp' , 2406params ={ { 'expr' , 'number' } } , 2407signature ='exp({expr})' , 2408see_lua ={ '|math.exp()|' } , 2409} , 2410expand ={ 2411args ={ 1 , 3 } , 2412base =1 , 2413desc =[=[ 2414Expand wildcards and the following special keywords in 2415{string}. 'wildignorecase' applies. 2416 2417If {list} is given and it is |TRUE|, a List will be returned. 2418Otherwise the result is a String and when there are several 2419matches, they are separated by <NL> characters. 2420 2421If the expansion fails, the result is an empty string. A name 2422for a non-existing file is not included, unless {string} does 2423not start with '%', '#' or '<', see below. 2424 2425When {string} starts with '%', '#' or '<', the expansion is 2426done like for the |cmdline-special| variables with their 2427associated modifiers. Here is a short overview: 2428 2429% Current file name 2430# Alternate file name 2431#n Alternate file name n 2432<cfile> File name under the cursor 2433<afile> Autocmd file name 2434<abuf> Autocmd buffer number (as a String!) 2435<amatch> Autocmd matched name 2436<cexpr> C expression under the cursor 2437<sfile> Deprecated, use <script> or <stack> 2438<slnum> Sourced script line number or function 2439line number 2440<sflnum> Script file line number, also when in 2441a function 2442<SID> "<SNR>123_" where "123" is the 2443current script ID |<SID>| 2444<script> Sourced script file, or script file 2445where the current function was defined. 2446Lua: see |lua-script-location|. 2447<stack> Call stack 2448<cword> Word under the cursor 2449<cWORD> WORD under the cursor 2450<client> The {clientid} of the last received 2451message 2452Modifiers: 2453:p Expand to full path 2454:h Head (last path component removed) 2455:t Tail (last path component only) 2456:r Root (one extension removed) 2457:e Extension only 2458 2459More modifiers are supported, for the full list see 2460|filename-modifiers|. 2461 2462Example: >vim 2463let &tags = expand("%:p:h") .. "/tags" 2464<Note that when expanding a string that starts with '%', '#' or 2465'<', any following text is ignored. This does NOT work: >vim 2466let doesntwork = expand("%:h.bak") 2467<Use this: >vim 2468let doeswork = expand("%:h") .. ".bak" 2469<Also note that expanding "<cfile>" and others only returns the 2470referenced file name without further expansion. If "<cfile>" 2471is "~/.cshrc", you need to do another expand() to have the 2472"~/" expanded into the path of the home directory: >vim 2473echo expand(expand("<cfile>")) 2474< 2475There cannot be white space between the variables and the 2476following modifier. The |fnamemodify()| function can be used 2477to modify normal file names. 2478 2479When using '%' or '#', and the current or alternate file name 2480is not defined, an empty string is used. Using "%:p" in a 2481buffer with no name, results in the current directory, with a 2482'/' added. 2483When 'verbose' is set then expanding '%', '#' and <> items 2484will result in an error message if the argument cannot be 2485expanded. 2486 2487When {string} does not start with '%', '#' or '<', it is 2488expanded like a file name is expanded on the command line. 2489'suffixes' and 'wildignore' are used, unless the optional 2490{nosuf} argument is given and it is |TRUE|. 2491Names for non-existing files are included. The "**" item can 2492be used to search in a directory tree. For example, to find 2493all "README" files in the current directory and below: >vim 2494echo expand("**/README") 2495< 2496expand() can also be used to expand variables and environment 2497variables that are only known in a shell. But this can be 2498slow, because a shell may be used to do the expansion. See 2499|expr-env-expand|. 2500The expanded variable is still handled like a list of file 2501names. When an environment variable cannot be expanded, it is 2502left unchanged. Thus ":echo expand('$FOOBAR')" results in 2503"$FOOBAR". 2504 2505See |glob()| for finding existing files. See |system()| for 2506getting the raw output of an external command. 2507 2508]=] , 2509name ='expand' , 2510params ={ { 'string' , 'string' } , { 'nosuf' , 'boolean' } , { 'list' , 'nil|false' } } , 2511signature ='expand({string} [, {nosuf} [, {list}]])' , 2512returns ='string' , 2513} , 2514expand__1 ={ 2515args ={ 3 } , 2516base =1 , 2517name ='expand' , 2518params ={ 2519{ 'string' , 'string' } , 2520{ 'nosuf' , 'boolean?' } , 2521{ 'list' , 'true|number|string|table' } , 2522} , 2523returns ='string|string[]' , 2524} , 2525expandcmd ={ 2526args ={ 1 , 2 } , 2527base =1 , 2528desc =[=[ 2529Expand special items in String {string} like what is done for 2530an Ex command such as `:edit`. This expands special keywords, 2531like with |expand()|, and environment variables, anywhere in 2532{string}. "~user" and "~/path" are only expanded at the 2533start. 2534The expansion is done in two steps: the special keywords are 2535evaluated first, then "~" and environment variables are 2536expanded in the result. Thus `expand('%:~')` keeps the "~", 2537while `expandcmd('%:~')` returns the full path. 2538 2539The following items are supported in the {options} Dict 2540argument: 2541errmsg If set to TRUE, error messages are displayed 2542if an error is encountered during expansion. 2543By default, error messages are not displayed. 2544 2545Returns the expanded string. If an error is encountered 2546during expansion, the unmodified {string} is returned. 2547 2548Example: >vim 2549echo expandcmd('make %<.o') 2550< > 2551make /path/runtime/doc/builtin.o 2552< >vim 2553echo expandcmd('make %<.o', {'errmsg': v:true}) 2554< 2555]=] , 2556name ='expandcmd' , 2557params ={ { 'string' , 'string' } , { 'options' , 'table' } } , 2558signature ='expandcmd({string} [, {options}])' , 2559} , 2560extend ={ 2561args ={ 2 , 3 } , 2562base =1 , 2563desc =[=[ 2564{expr1} and {expr2} must be both |Lists| or both 2565|Dictionaries|. 2566 2567If they are |Lists|: Append {expr2} to {expr1}. 2568If {expr3} is given insert the items of {expr2} before the 2569item with index {expr3} in {expr1}. When {expr3} is zero 2570insert before the first item. When {expr3} is equal to 2571len({expr1}) then {expr2} is appended. 2572Examples: >vim 2573echo sort(extend(mylist, [7, 5])) 2574call extend(mylist, [2, 3], 1) 2575<When {expr1} is the same List as {expr2} then the number of 2576items copied is equal to the original length of the List. 2577E.g., when {expr3} is 1 you get N new copies of the first item 2578(where N is the original length of the List). 2579Use |add()| to concatenate one item to a list. To concatenate 2580two lists into a new list use the + operator: >vim 2581let newlist = [1, 2, 3] + [4, 5] 2582< 2583If they are |Dictionaries|: 2584Add all entries from {expr2} to {expr1}. 2585If a key exists in both {expr1} and {expr2} then {expr3} is 2586used to decide what to do: 2587{expr3} = "keep": keep the value of {expr1} 2588{expr3} = "force": use the value of {expr2} 2589{expr3} = "error": give an error message *E737* 2590When {expr3} is omitted then "force" is assumed. 2591 2592{expr1} is changed when {expr2} is not empty. If necessary 2593make a copy of {expr1} first or use |extendnew()| to return a 2594new List/Dictionary. 2595{expr2} remains unchanged. 2596When {expr1} is locked and {expr2} is not empty the operation 2597fails. 2598Returns {expr1}. Returns 0 on error. 2599 2600]=] , 2601name ='extend' , 2602params ={ { 'expr1' , 'table' } , { 'expr2' , 'table' } , { 'expr3' , 'table' } } , 2603signature ='extend({expr1}, {expr2} [, {expr3}])' , 2604see_lua ={ 2605'|vim.list_extend()| for lists, or |vim.tbl_extend()| and |vim.tbl_deep_extend()| for dicts; insertion and keep/force/error behavior differ' , 2606} , 2607} , 2608extendnew ={ 2609args ={ 2 , 3 } , 2610base =1 , 2611desc =[=[ 2612Like |extend()| but instead of adding items to {expr1} a new 2613List or Dictionary is created and returned. {expr1} remains 2614unchanged. 2615]=] , 2616name ='extendnew' , 2617params ={ { 'expr1' , 'table' } , { 'expr2' , 'table' } , { 'expr3' , 'table' } } , 2618signature ='extendnew({expr1}, {expr2} [, {expr3}])' , 2619see_lua ={ 2620'|vim.list_extend()| on a copy for lists, or |vim.tbl_extend()| and |vim.tbl_deep_extend()| for dicts; insertion and keep/force/error behavior differ' , 2621} , 2622} , 2623feedkeys ={ 2624args ={ 1 , 2 } , 2625base =1 , 2626desc =[=[ 2627Characters in {string} are queued for processing as if they 2628come from a mapping or were typed by the user. 2629 2630By default the string is added to the end of the typeahead 2631buffer, thus if a mapping is still being executed the 2632characters come after them. Use the 'i' flag to insert before 2633other characters, they will be executed next, before any 2634characters from a mapping. 2635 2636The function does not wait for processing of keys contained in 2637{string}. 2638 2639To include special keys into {string}, use double-quotes 2640and "\..." notation |expr-quote|. For example, 2641feedkeys("\<CR>") simulates pressing of the <Enter> key. But 2642feedkeys('\<CR>') pushes 5 characters. 2643The |<Ignore>| keycode may be used to exit the 2644wait-for-character without doing anything. 2645 2646{mode} is a String, which can contain these character flags: 2647'm' Remap keys. This is default. If {mode} is absent, 2648keys are remapped. 2649'n' Do not remap keys. 2650't' Handle keys as if typed; otherwise they are handled as 2651if coming from a mapping. This matters for undo, 2652opening folds, etc. 2653'L' Lowlevel input. Other flags are not used. 2654'i' Insert the string instead of appending (see above). 2655'x' Execute commands until typeahead is empty. This is 2656similar to using ":normal!". You can call feedkeys() 2657several times without 'x' and then one time with 'x' 2658(possibly with an empty {string}) to execute all the 2659typeahead. Note that when Vim ends in Insert mode it 2660will behave as if <Esc> is typed, to avoid getting 2661stuck, waiting for a character to be typed before the 2662script continues. 2663Note that if you manage to call feedkeys() while 2664executing commands, thus calling it recursively, then 2665all typeahead will be consumed by the last call. 2666'!' When used with 'x' will not end Insert mode. Can be 2667used in a test when a timer is set to exit Insert mode 2668a little later. Useful for testing CursorHoldI. 2669 2670Return value is always 0. 2671 2672]=] , 2673name ='feedkeys' , 2674params ={ { 'string' , 'string' } , { 'mode' , 'string' } } , 2675signature ='feedkeys({string} [, {mode}])' , 2676see_lua ={ '|nvim_feedkeys()|' } , 2677} , 2678file_readable ={ 2679args =1 , 2680base =1 , 2681deprecated =true , 2682desc =[=[ 2683Obsolete name for |filereadable()|. 2684]=] , 2685func ='f_filereadable' , 2686name ='file_readable' , 2687params ={ { 'file' , 'string' } } , 2688signature ='file_readable({file})' , 2689see_lua ={ '|uv.fs_access()| with `"R"` and |uv.fs_stat()| to exclude directories' } , 2690} , 2691filecopy ={ 2692args =2 , 2693base =1 , 2694desc =[[ 2695Copy the file pointed to by the name {from} to {to}. The 2696result is a Number, which is |TRUE| if the file was copied 2697successfully, and |FALSE| when it failed. 2698If a file with name {to} already exists, it will fail. 2699Note that it does not handle directories (yet). 2700 2701This function is not available in the |sandbox|. 2702]] , 2703name ='filecopy' , 2704params ={ { 'from' , 'string' } , { 'to' , 'string' } } , 2705returns ='0|1' , 2706signature ='filecopy({from}, {to})' , 2707see_lua ={ '|uv.fs_copyfile()| with `{ excl = true }`; return semantics differ' } , 2708} , 2709filereadable ={ 2710args =1 , 2711base =1 , 2712desc =[=[ 2713Returns |TRUE| if {file} exists, can be read, and is not 2714a directory, else |FALSE|. 2715 2716{file} is any expression, which is used as a String. If you 2717don't care about the file being readable you can use |glob()|. 2718 2719{file} is used as-is, you may want to expand wildcards first: >vim 2720echo filereadable('~/.vimrc') 2721< > 27220 2723< >vim 2724echo filereadable(expand('~/.vimrc')) 2725< > 27261 2727< 2728 2729]=] , 2730fast =true , 2731name ='filereadable' , 2732params ={ { 'file' , 'string' } } , 2733returns ='0|1' , 2734signature ='filereadable({file})' , 2735see_lua ={ '|uv.fs_access()| with `"R"` and |uv.fs_stat()| to exclude directories' } , 2736} , 2737filewritable ={ 2738args =1 , 2739base =1 , 2740desc =[=[ 2741Checks whether a file with the name {file} exists and can 2742be written. Returns 1 if so. If {file} doesn't exist, or 2743is not writable, the result is 0. If {file} is a 2744directory, and we can write to it, the result is 2. 2745 2746]=] , 2747fast =true , 2748name ='filewritable' , 2749params ={ { 'file' , 'string' } } , 2750returns ='0|1' , 2751signature ='filewritable({file})' , 2752see_lua ={ 2753'|uv.fs_access()| with `"W"` and |uv.fs_stat()| if you need Vim\'s `2` return for directories' , 2754} , 2755} , 2756filter ={ 2757args =2 , 2758base =1 , 2759desc =[=[ 2760{expr1} must be a |List|, |String|, |Blob| or |Dictionary|. 2761For each item in {expr1} evaluate {expr2} and when the result 2762is zero or false remove the item from the |List| or 2763|Dictionary|. Similarly for each byte in a |Blob| and each 2764character in a |String|. 2765 2766{expr2} must be a |string| or |Funcref|. 2767 2768If {expr2} is a |string|, inside {expr2} |v:val| has the value 2769of the current item. For a |Dictionary| |v:key| has the key 2770of the current item and for a |List| |v:key| has the index of 2771the current item. For a |Blob| |v:key| has the index of the 2772current byte. For a |String| |v:key| has the index of the 2773current character. 2774Examples: >vim 2775call filter(mylist, 'v:val !~ "OLD"') 2776<Removes the items where "OLD" appears. >vim 2777call filter(mydict, 'v:key >= 8') 2778<Removes the items with a key below 8. >vim 2779call filter(var, 0) 2780<Removes all the items, thus clears the |List| or |Dictionary|. 2781 2782Note that {expr2} is the result of expression and is then 2783used as an expression again. Often it is good to use a 2784|literal-string| to avoid having to double backslashes. 2785 2786If {expr2} is a |Funcref| it must take two arguments: 27871. the key or the index of the current item. 27882. the value of the current item. 2789The function must return |TRUE| if the item should be kept. 2790Example that keeps the odd items of a list: >vim 2791func Odd(idx, val) 2792return a:idx % 2 == 1 2793endfunc 2794call filter(mylist, function('Odd')) 2795<It is shorter when using a |lambda|: >vim 2796call filter(myList, {idx, val -> idx * val <= 42}) 2797<If you do not use "val" you can leave it out: >vim 2798call filter(myList, {idx -> idx % 2 == 1}) 2799< 2800For a |List| and a |Dictionary| the operation is done 2801in-place. If you want it to remain unmodified make a copy 2802first: >vim 2803let l = filter(copy(mylist), 'v:val =~ "KEEP"') 2804 2805<Returns {expr1}, the |List| or |Dictionary| that was filtered, 2806or a new |Blob| or |String|. 2807When an error is encountered while evaluating {expr2} no 2808further items in {expr1} are processed. 2809When {expr2} is a Funcref errors inside a function are 2810ignored, unless it was defined with the "abort" flag. 2811 2812]=] , 2813name ='filter' , 2814params ={ { 'expr1' , 'string|table' } , { 'expr2' , 'string|function' } } , 2815signature ='filter({expr1}, {expr2})' , 2816see_lua ={ '|vim.tbl_filter()| for lists; dicts, strings, and blobs differ' } , 2817} , 2818finddir ={ 2819args ={ 1 , 3 } , 2820base =1 , 2821desc =[=[ 2822Find directory {name} in {path}. Supports both downwards and 2823upwards recursive directory searches. See |file-searching| 2824for the syntax of {path}. 2825 2826Returns the path of the first found match. When the found 2827directory is below the current directory a relative path is 2828returned. Otherwise a full path is returned. 2829If {path} is omitted or empty then 'path' is used. 2830 2831If the optional {count} is given, find {count}'s occurrence of 2832{name} in {path} instead of the first one. 2833When {count} is negative return all the matches in a |List|. 2834 2835Returns an empty string if the directory is not found. 2836 2837This is quite similar to the ex-command `:find`. 2838 2839]=] , 2840name ='finddir' , 2841params ={ { 'name' , 'string' } , { 'path' , 'string' } , { 'count' , 'integer' } } , 2842returns ='string|string[]' , 2843signature ='finddir({name} [, {path} [, {count}]])' , 2844see_lua ={ 2845"|vim.fs.find()| with `type = 'directory'`; `path`, `count`, and return semantics differ" , 2846} , 2847} , 2848findfile ={ 2849args ={ 1 , 3 } , 2850base =1 , 2851desc =[=[ 2852Just like |finddir()|, but find a file instead of a directory. 2853Uses 'suffixesadd'. 2854Example: >vim 2855echo findfile("tags.vim", ".;") 2856<Searches from the directory of the current file upwards until 2857it finds the file "tags.vim". 2858 2859]=] , 2860name ='findfile' , 2861params ={ { 'name' , 'string' } , { 'path' , 'string' } , { 'count' , 'integer' } } , 2862returns ='string|string[]' , 2863signature ='findfile({name} [, {path} [, {count}]])' , 2864see_lua ={ 2865"|vim.fs.find()|; `path`, `count`, return semantics, and |'suffixesadd'| handling differ" , 2866} , 2867} , 2868flatten ={ 2869args ={ 1 , 2 } , 2870base =1 , 2871desc =[=[ 2872Flatten {list} up to {maxdepth} levels. Without {maxdepth} 2873the result is a |List| without nesting, as if {maxdepth} is 2874a very large number. 2875The {list} is changed in place, use |flattennew()| if you do 2876not want that. 2877*E900* 2878{maxdepth} means how deep in nested lists changes are made. 2879{list} is not modified when {maxdepth} is 0. 2880{maxdepth} must be positive number. 2881 2882If there is an error the number zero is returned. 2883 2884Example: >vim 2885echo flatten([1, [2, [3, 4]], 5]) 2886< [1, 2, 3, 4, 5] >vim 2887echo flatten([1, [2, [3, 4]], 5], 1) 2888< [1, 2, [3, 4], 5] 2889 2890]=] , 2891name ='flatten' , 2892params ={ { 'list' , 'any[]' } , { 'maxdepth' , 'integer' } } , 2893returns ='any[]|0' , 2894signature ='flatten({list} [, {maxdepth}])' , 2895see_lua ={ 2896'`vim.iter(list):flatten():totable()` for a new flattened list; in-place updates and `maxdepth` differ' , 2897} , 2898} , 2899flattennew ={ 2900args ={ 1 , 2 } , 2901base =1 , 2902desc =[=[ 2903Like |flatten()| but first make a copy of {list}. 2904]=] , 2905name ='flattennew' , 2906params ={ { 'list' , 'any[]' } , { 'maxdepth' , 'integer' } } , 2907returns ='any[]|0' , 2908signature ='flattennew({list} [, {maxdepth}])' , 2909see_lua ={ 2910'`vim.iter(list):flatten():totable()` for a new flattened list; `maxdepth` differs' , 2911} , 2912} , 2913float2nr ={ 2914args =1 , 2915base =1 , 2916desc =[=[ 2917Convert {expr} to a Number by omitting the part after the 2918decimal point. 2919{expr} must evaluate to a |Float| or a |Number|. 2920Returns 0 if {expr} is not a |Float| or a |Number|. 2921When the value of {expr} is out of range for a |Number| the 2922result is truncated to 0x7fffffff or -0x7fffffff (or when 292364-bit Number support is enabled, 0x7fffffffffffffff or 2924-0x7fffffffffffffff). NaN results in -0x80000000 (or when 292564-bit Number support is enabled, -0x8000000000000000). 2926Examples: >vim 2927echo float2nr(3.95) 2928< 3 >vim 2929echo float2nr(-23.45) 2930< -23 >vim 2931echo float2nr(1.0e100) 2932< 2147483647 (or 9223372036854775807) >vim 2933echo float2nr(-1.0e150) 2934< -2147483647 (or -9223372036854775807) >vim 2935echo float2nr(1.0e-100) 2936< 0 2937 2938]=] , 2939name ='float2nr' , 2940params ={ { 'expr' , 'number' } } , 2941signature ='float2nr({expr})' , 2942see_lua ={ '|math.modf()| (first return value)' } , 2943} , 2944floor ={ 2945args =1 , 2946base =1 , 2947desc =[=[ 2948Return the largest integral value less than or equal to 2949{expr} as a |Float| (round down). 2950{expr} must evaluate to a |Float| or a |Number|. 2951Returns 0.0 if {expr} is not a |Float| or a |Number|. 2952Examples: >vim 2953echo floor(1.856) 2954< 1.0 >vim 2955echo floor(-5.456) 2956< -6.0 >vim 2957echo floor(4.0) 2958< 4.0 2959 2960]=] , 2961func_float ='floor' , 2962name ='floor' , 2963params ={ { 'expr' , 'number' } } , 2964signature ='floor({expr})' , 2965see_lua ={ '|math.floor()|' } , 2966} , 2967fmod ={ 2968args =2 , 2969base =1 , 2970desc =[=[ 2971Return the remainder of {expr1} / {expr2}, even if the 2972division is not representable. Returns {expr1} - i * {expr2} 2973for some integer i such that if {expr2} is non-zero, the 2974result has the same sign as {expr1} and magnitude less than 2975the magnitude of {expr2}. If {expr2} is zero, the value 2976returned is zero. The value returned is a |Float|. 2977{expr1} and {expr2} must evaluate to a |Float| or a |Number|. 2978Returns 0.0 if {expr1} or {expr2} is not a |Float| or a 2979|Number|. 2980Examples: >vim 2981echo fmod(12.33, 1.22) 2982< 0.13 >vim 2983echo fmod(-12.33, 1.22) 2984< -0.13 2985 2986]=] , 2987name ='fmod' , 2988params ={ { 'expr1' , 'number' } , { 'expr2' , 'number' } } , 2989signature ='fmod({expr1}, {expr2})' , 2990see_lua ={ '|math.fmod()|' } , 2991} , 2992fnameescape ={ 2993args =1 , 2994base =1 , 2995desc =[=[ 2996Escapes {filepath} for use as a command argument. 2997 2998(Note: To open a literal filepath programmatically use 2999`bufadd(vim.fs.normalize(…))`, see |open-file|.) 3000 3001All characters that have a special meaning, such as `'%'` and 3002`'|'` are escaped with a backslash. For most systems the 3003characters escaped are: > 3004\t\n *?[{`$\\%#'\"|!< 3005<For systems where a backslash appears in a filename, it 3006depends on the value of 'isfname'. A leading '+' and '>' is 3007also escaped (special after |:edit| and |:write|). And a "-" 3008by itself (special after |:cd|). 3009Returns an empty string on error. 3010Example: >vim 3011let fname = '+some str%nge|name' 3012exe "edit " .. fnameescape(fname) 3013<results in executing: >vim 3014edit \+some\ str\%nge\|name 3015< 3016]=] , 3017fast =true , 3018name ='fnameescape' , 3019params ={ { 'filepath' , 'string' } } , 3020returns ='string' , 3021signature ='fnameescape({filepath})' , 3022} , 3023fnamemodify ={ 3024args =2 , 3025base =1 , 3026desc =[=[ 3027Modify file name {fname} according to {mods}. {mods} is a 3028string of characters like it is used for file names on the 3029command line. See |filename-modifiers|. 3030Example: >vim 3031echo fnamemodify("main.c", ":p:h") 3032<results in: > 3033/home/user/vim/vim/src 3034<If {mods} is empty or an unsupported modifier is used then 3035{fname} is returned. 3036When {fname} is empty then with {mods} ":h" returns ".", so 3037that `:cd` can be used with it. This is different from 3038expand('%:h') without a buffer name, which returns an empty 3039string. 3040Note: Environment variables don't work in {fname}, use 3041|expand()| first then. 3042 3043]=] , 3044fast =true , 3045name ='fnamemodify' , 3046params ={ { 'fname' , 'string' } , { 'mods' , 'string' } } , 3047returns ='string' , 3048signature ='fnamemodify({fname}, {mods})' , 3049see_lua ={ 3050'|vim.fs.dirname()|, |vim.fs.basename()|, |vim.fs.abspath()|, and |vim.fs.normalize()| for common path modifiers; modifier coverage differs' , 3051} , 3052} , 3053foldclosed ={ 3054args =1 , 3055base =1 , 3056desc =[=[ 3057Returns the first line number of the closed fold containing 3058line {lnum}. If the line {lnum} is not in a closed fold, 3059-1 is returned. 3060{lnum} is used like with |getline()|. Thus "." is the current 3061line, "'m" mark m, etc. 3062 3063]=] , 3064name ='foldclosed' , 3065params ={ { 'lnum' , 'integer|string' } } , 3066returns ='integer' , 3067signature ='foldclosed({lnum})' , 3068} , 3069foldclosedend ={ 3070args =1 , 3071base =1 , 3072desc =[=[ 3073Returns the last line number of the closed fold containing 3074line {lnum}. If the line {lnum} is not in a closed fold, 3075-1 is returned. 3076{lnum} is used like with |getline()|. Thus "." is the current 3077line, "'m" mark m, etc. 3078 3079]=] , 3080name ='foldclosedend' , 3081params ={ { 'lnum' , 'integer|string' } } , 3082returns ='integer' , 3083signature ='foldclosedend({lnum})' , 3084} , 3085foldlevel ={ 3086args =1 , 3087base =1 , 3088desc =[=[ 3089Returns the fold nesting level of line {lnum} in the current 3090buffer. {lnum} is used like with |getline()| ("." is the 3091current line, "'m" mark m, etc). 3092 3093For nested folds the deepest level is returned. If there is 3094no fold at line {lnum}, zero is returned. It doesn't matter 3095if the folds are open or closed. When used while updating 3096folds (from 'foldexpr') -1 is returned for lines where folds 3097are still to be updated and the foldlevel is unknown. As 3098a special case the level of the previous line is usually 3099available. 3100]=] , 3101name ='foldlevel' , 3102params ={ { 'lnum' , 'integer|string' } } , 3103returns ='integer' , 3104signature ='foldlevel({lnum})' , 3105} , 3106foldtext ={ 3107desc =[=[ 3108Returns a String, to be displayed for a closed fold. This is 3109the default function used for the 'foldtext' option and should 3110only be called from evaluating 'foldtext'. It uses the 3111|v:foldstart|, |v:foldend| and |v:folddashes| variables. 3112The returned string looks like this: > 3113+-- 45 lines: abcdef 3114<The number of leading dashes depends on the foldlevel. The 3115"45" is the number of lines in the fold. "abcdef" is the text 3116in the first non-blank line of the fold. Leading white space, 3117"//" or "/*" and the text from the 'foldmarker' and 3118'commentstring' options is removed. 3119When used to draw the actual foldtext, the rest of the line 3120will be filled with the fold char from the 'fillchars' 3121setting. 3122Returns an empty string when there is no fold. 3123]=] , 3124name ='foldtext' , 3125params ={} , 3126returns ='string' , 3127signature ='foldtext()' , 3128} , 3129foldtextresult ={ 3130args =1 , 3131base =1 , 3132desc =[=[ 3133Returns the text that is displayed for the closed fold at line 3134{lnum}. Evaluates 'foldtext' in the appropriate context. 3135When there is no closed fold at {lnum} an empty string is 3136returned. 3137{lnum} is used like with |getline()|. Thus "." is the current 3138line, "'m" mark m, etc. 3139Useful when exporting folded text, e.g., to HTML. 3140 3141]=] , 3142name ='foldtextresult' , 3143params ={ { 'lnum' , 'integer|string' } } , 3144returns ='string' , 3145signature ='foldtextresult({lnum})' , 3146} , 3147foreach ={ 3148args =2 , 3149base =1 , 3150desc =[=[ 3151{expr1} must be a |List|, |String|, |Blob| or |Dictionary|. 3152For each item in {expr1} execute {expr2}. {expr1} is not 3153modified; its values may be, as with |:lockvar| 1. |E741| 3154See |map()| and |filter()| to modify {expr1}. 3155 3156{expr2} must be a |string| or |Funcref|. 3157 3158If {expr2} is a |string|, inside {expr2} |v:val| has the value 3159of the current item. For a |Dictionary| |v:key| has the key 3160of the current item and for a |List| |v:key| has the index of 3161the current item. For a |Blob| |v:key| has the index of the 3162current byte. For a |String| |v:key| has the index of the 3163current character. 3164Examples: >vim 3165call foreach(mylist, 'let used[v:val] = v:true') 3166<This records the items that are in the {expr1} list. 3167 3168Note that {expr2} is the result of expression and is then used 3169as a command. Often it is good to use a |literal-string| to 3170avoid having to double backslashes. 3171 3172If {expr2} is a |Funcref| it must take two arguments: 31731. the key or the index of the current item. 31742. the value of the current item. 3175With a lambda you don't get an error if it only accepts one 3176argument. 3177If the function returns a value, it is ignored. 3178 3179Returns {expr1} in all cases. 3180When an error is encountered while executing {expr2} no 3181further items in {expr1} are processed. 3182When {expr2} is a Funcref errors inside a function are 3183ignored, unless it was defined with the "abort" flag. 3184]=] , 3185name ='foreach' , 3186params ={ { 'expr1' , 'string|table' } , { 'expr2' , 'string|function' } } , 3187returns ='string|table' , 3188signature ='foreach({expr1}, {expr2})' , 3189see_lua ={ '|pairs()|' , '|ipairs()|' } , 3190} , 3191foreground ={ 3192args =0 , 3193params ={} , 3194lua =false , 3195} , 3196fullcommand ={ 3197args =1 , 3198base =1 , 3199desc =[=[ 3200Get the full command name from a short abbreviated command 3201name; see |20.2| for details on command abbreviations. 3202 3203The string argument {name} may start with a `:` and can 3204include a [range], these are skipped and not returned. 3205Returns an empty string if a command doesn't exist or if it's 3206ambiguous (for user-defined commands). 3207 3208Note: Command validation is not performed. Results depend on 3209Vim's internal command-specific identification rules. 3210Examples: 3211>vim 3212echo [fullcommand('s')] |" ['substitute'] 3213echo [fullcommand('sub')] |" ['substitute'] 3214echo [fullcommand(': mark word')] |" ['mark'] 3215echo [fullcommand(': markword')] |" [''] 3216echo [fullcommand('en')] |" ['endif'] 3217< 3218]=] , 3219name ='fullcommand' , 3220params ={ { 'name' , 'string' } } , 3221returns ='string' , 3222signature ='fullcommand({name})' , 3223} , 3224funcref ={ 3225args ={ 1 , 3 } , 3226base =1 , 3227desc =[=[ 3228Just like |function()|, but the returned Funcref will lookup 3229the function by reference, not by name. This matters when the 3230function {name} is redefined later. 3231 3232Unlike |function()|, {name} must be an existing user function. 3233It only works for an autoloaded function if it has already 3234been loaded (to avoid mistakenly loading the autoload script 3235when only intending to use the function name, use |function()| 3236instead). {name} cannot be a builtin function. 3237Returns 0 on error. 3238 3239]=] , 3240name ='funcref' , 3241params ={ { 'name' , 'string' } , { 'arglist' , 'any' } , { 'dict' , 'any' } } , 3242signature ='funcref({name} [, {arglist}] [, {dict}])' , 3243see_lua =false , 3244} , 3245[ 'function' ] ={ 3246args ={ 1 , 3 } , 3247base =1 , 3248desc =[=[ 3249Return a |Funcref| variable that refers to function {name}. 3250{name} can be the name of a user defined function or an 3251internal function. 3252 3253{name} can also be a Funcref or a partial. When it is a 3254partial the dict stored in it will be used and the {dict} 3255argument is not allowed. E.g.: >vim 3256let FuncWithArg = function(dict.Func, [arg]) 3257let Broken = function(dict.Func, [arg], dict) 3258< 3259When using the Funcref the function will be found by {name}, 3260also when it was redefined later. Use |funcref()| to keep the 3261same function. 3262 3263When {arglist} or {dict} is present this creates a partial. 3264That means the argument list and/or the dictionary is stored 3265in the Funcref and will be used when the Funcref is called. 3266 3267The arguments are passed to the function in front of other 3268arguments, but after any argument from |method|. Example: >vim 3269func Callback(arg1, arg2, name) 3270"... 3271endfunc 3272let Partial = function('Callback', ['one', 'two']) 3273"... 3274call Partial('name') 3275<Invokes the function as with: >vim 3276call Callback('one', 'two', 'name') 3277 3278<With a |method|: >vim 3279func Callback(one, two, three) 3280"... 3281endfunc 3282let Partial = function('Callback', ['two']) 3283"... 3284eval 'one'->Partial('three') 3285<Invokes the function as with: >vim 3286call Callback('one', 'two', 'three') 3287 3288<The function() call can be nested to add more arguments to the 3289Funcref. The extra arguments are appended to the list of 3290arguments. Example: >vim 3291func Callback(arg1, arg2, name) 3292"... 3293endfunc 3294let Func = function('Callback', ['one']) 3295let Func2 = function(Func, ['two']) 3296"... 3297call Func2('name') 3298<Invokes the function as with: >vim 3299call Callback('one', 'two', 'name') 3300 3301<The Dictionary is only useful when calling a "dict" function. 3302In that case the {dict} is passed in as "self". Example: >vim 3303function Callback() dict 3304echo "called for " .. self.name 3305endfunction 3306"... 3307let context = {"name": "example"} 3308let Func = function('Callback', context) 3309"... 3310call Func() " will echo: called for example 3311<The use of function() is not needed when there are no extra 3312arguments, these two are equivalent, if Callback() is defined 3313as context.Callback(): >vim 3314let Func = function('Callback', context) 3315let Func = context.Callback 3316 3317<The argument list and the Dictionary can be combined: >vim 3318function Callback(arg1, count) dict 3319"... 3320endfunction 3321let context = {"name": "example"} 3322let Func = function('Callback', ['one'], context) 3323"... 3324call Func(500) 3325<Invokes the function as with: >vim 3326call context.Callback('one', 500) 3327< 3328Returns 0 on error. 3329 3330]=] , 3331name ='function' , 3332params ={ { 'name' , 'string' } , { 'arglist' , 'any' } , { 'dict' , 'any' } } , 3333signature ='function({name} [, {arglist}] [, {dict}])' , 3334tags ={ 'partial' , 'E700' , 'E923' } , 3335see_lua =false , 3336} , 3337garbagecollect ={ 3338args ={ 0 , 1 } , 3339desc =[=[ 3340Cleanup unused |Lists| and |Dictionaries| that have circular 3341references. 3342 3343There is hardly ever a need to invoke this function, as it is 3344automatically done when Vim runs out of memory or is waiting 3345for the user to press a key after 'updatetime'. Items without 3346circular references are always freed when they become unused. 3347This is useful if you have deleted a very big |List| and/or 3348|Dictionary| with circular references in a script that runs 3349for a long time. 3350 3351When the optional {atexit} argument is one, garbage 3352collection will also be done when exiting Vim, if it wasn't 3353done before. This is useful when checking for memory leaks. 3354 3355The garbage collection is not done immediately but only when 3356it's safe to perform. This is when waiting for the user to 3357type a character. 3358]=] , 3359name ='garbagecollect' , 3360params ={ { 'atexit' , 'boolean' } } , 3361signature ='garbagecollect([{atexit}])' , 3362see_lua =false , 3363} , 3364get ={ 3365args ={ 2 , 3 } , 3366base =1 , 3367desc =[=[ 3368Get item {idx} from |List| {list}. When this item is not 3369available return {default}. Return zero when {default} is 3370omitted. 3371]=] , 3372name ='get' , 3373params ={ { 'list' , 'any[]' } , { 'idx' , 'integer' } , { 'default' , 'any' } } , 3374signature ='get({list}, {idx} [, {default}])' , 3375tags ={ 'get()-list' } , 3376see_lua =false , 3377} , 3378get__1 ={ 3379args ={ 2 , 3 } , 3380base =1 , 3381desc =[=[ 3382Get byte {idx} from |Blob| {blob}. When this byte is not 3383available return {default}. Return -1 when {default} is 3384omitted. 3385]=] , 3386name ='get' , 3387params ={ { 'blob' , 'string' } , { 'idx' , 'integer' } , { 'default' , 'any' } } , 3388signature ='get({blob}, {idx} [, {default}])' , 3389tags ={ 'get()-blob' } , 3390see_lua =false , 3391} , 3392get__2 ={ 3393args ={ 2 , 3 } , 3394base =1 , 3395desc =[=[ 3396Get item with key {key} from |Dictionary| {dict}. When this 3397item is not available return {default}. Return zero when 3398{default} is omitted. Useful example: >vim 3399let val = get(g:, 'var_name', 'default') 3400<This gets the value of g:var_name if it exists, and uses 3401"default" when it does not exist. 3402]=] , 3403name ='get' , 3404params ={ { 'dict' , 'table<string,any>' } , { 'key' , 'string' } , { 'default' , 'any' } } , 3405signature ='get({dict}, {key} [, {default}])' , 3406tags ={ 'get()-dict' } , 3407see_lua =false , 3408} , 3409get__3 ={ 3410args ={ 2 , 3 } , 3411base =1 , 3412desc =[=[ 3413Get item {what} from |Funcref| {func}. Possible values for 3414{what} are: 3415"name" The function name 3416"func" The function 3417"dict" The dictionary 3418"args" The list with arguments 3419"arity" A dictionary with information about the number of 3420arguments accepted by the function (minus the 3421{arglist}) with the following fields: 3422required the number of positional arguments 3423optional the number of optional arguments, 3424in addition to the required ones 3425varargs |TRUE| if the function accepts a 3426variable number of arguments |...| 3427 3428Note: There is no error, if the {arglist} of 3429the Funcref contains more arguments than the 3430Funcref expects, it's not validated. 3431 3432Returns zero on error. 3433]=] , 3434name ='get' , 3435params ={ { 'func' , 'function' } , { 'what' , 'string' } } , 3436returns ='any' , 3437signature ='get({func}, {what})' , 3438tags ={ 'get()-func' } , 3439see_lua =false , 3440} , 3441getbufinfo ={ 3442args ={ 0 , 1 } , 3443base =1 , 3444name ='getbufinfo' , 3445params ={ { 'buf' , 'integer|string' } } , 3446signature ='getbufinfo([{buf}])' , 3447returns ='vim.fn.getbufinfo.ret.item[]' , 3448} , 3449getbufinfo__1 ={ 3450args ={ 0 , 1 } , 3451base =1 , 3452desc =[=[ 3453Get information about buffers as a List of Dictionaries. 3454 3455Without an argument information about all the buffers is 3456returned. 3457 3458When the argument is a |Dictionary| only the buffers matching 3459the specified criteria are returned. The following keys can 3460be specified in {dict}: 3461buflisted include only listed buffers. 3462bufloaded include only loaded buffers. 3463bufmodified include only modified buffers. 3464 3465Otherwise, {buf} specifies a particular buffer to return 3466information for. For the use of {buf}, see |bufname()| 3467above. If the buffer is found the returned List has one item. 3468Otherwise the result is an empty list. 3469 3470Each returned List item is a dictionary with the following 3471entries: 3472bufnr Buffer number. 3473changed TRUE if the buffer is modified. 3474changedtick Number of changes made to the buffer. 3475command TRUE if the buffer belongs to the 3476command-line window |cmdwin|. 3477hidden TRUE if the buffer is hidden. 3478lastused Timestamp in seconds, like 3479|localtime()|, when the buffer was 3480last used. 3481listed TRUE if the buffer is listed. 3482lnum Line number used for the buffer when 3483opened in the current window. 3484Only valid if the buffer has been 3485displayed in the window in the past. 3486If you want the line number of the 3487last known cursor position in a given 3488window, use |line()|: >vim 3489echo line('.', {winid}) 3490< 3491linecount Number of lines in the buffer (only 3492valid when loaded) 3493loaded TRUE if the buffer is loaded. 3494name Full path to the file in the buffer. 3495signs List of signs placed in the buffer. 3496Each list item is a dictionary with 3497the following fields: 3498id sign identifier 3499lnum line number 3500name sign name 3501variables A reference to the dictionary with 3502buffer-local variables. 3503windows List of |window-ID|s that display this 3504buffer 3505 3506Examples: >vim 3507for buf in getbufinfo() 3508echo buf.name 3509endfor 3510for buf in getbufinfo({'buflisted':1}) 3511if buf.changed 3512" .... 3513endif 3514endfor 3515< 3516To get buffer-local options use: >vim 3517getbufvar({bufnr}, '&option_name') 3518< 3519]=] , 3520name ='getbufinfo' , 3521params ={ { 'dict' , 'vim.fn.getbufinfo.dict' } } , 3522signature ='getbufinfo([{dict}])' , 3523returns ='vim.fn.getbufinfo.ret.item[]' , 3524} , 3525getbufline ={ 3526args ={ 2 , 3 } , 3527base =1 , 3528desc =[=[ 3529Return a |List| with the lines starting from {lnum} to {end} 3530(inclusive) in the buffer {buf}. If {end} is omitted, a 3531|List| with only the line {lnum} is returned. See 3532`getbufoneline()` for only getting the line. 3533 3534For the use of {buf}, see |bufname()| above. 3535 3536For {lnum} and {end} "$" can be used for the last line of the 3537buffer. Otherwise a number must be used. 3538 3539When {lnum} is smaller than 1 or bigger than the number of 3540lines in the buffer, an empty |List| is returned. 3541 3542When {end} is greater than the number of lines in the buffer, 3543it is treated as {end} is set to the number of lines in the 3544buffer. When {end} is before {lnum} an empty |List| is 3545returned. 3546 3547This function works only for loaded buffers. For unloaded and 3548non-existing buffers, an empty |List| is returned. 3549 3550Example: >vim 3551let lines = getbufline(bufnr("myfile"), 1, "$") 3552< 3553 3554]=] , 3555name ='getbufline' , 3556params ={ { 'buf' , 'integer|string' } , { 'lnum' , 'integer' } , { 'end' , 'integer' } } , 3557returns ='string[]' , 3558signature ='getbufline({buf}, {lnum} [, {end}])' , 3559see_lua ={ '|nvim_buf_get_lines()|' } , 3560} , 3561getbufoneline ={ 3562args =2 , 3563base =1 , 3564desc =[=[ 3565Just like `getbufline()` but only get one line and return it 3566as a string. 3567]=] , 3568name ='getbufoneline' , 3569params ={ { 'buf' , 'integer|string' } , { 'lnum' , 'integer' } } , 3570signature ='getbufoneline({buf}, {lnum})' , 3571returns ='string' , 3572see_lua ={ '|nvim_buf_get_lines()|' } , 3573} , 3574getbufvar ={ 3575args ={ 2 , 3 } , 3576base =1 , 3577desc =[=[ 3578Gets the value of a buffer-local variable or option {varname} 3579in buffer {buf}. 3580 3581{varname} is a string: 3582- Name of the variable (without "b:"). 3583- If empty, gets a |Dictionary| of all buffer-local variables. 3584- If "&", gets a |Dictionary| of all buffer-local options. 3585- If it starts with "&", gets the value of a buffer-local 3586option. 3587 3588{buf} has the same form as in |bufname()|. 3589 3590Also works for a global or buffer-local option. But not for 3591a global variable, window-local variable or window-local 3592option. 3593 3594When the buffer or variable doesn't exist, {def} or an empty 3595string is returned; there is no error. 3596 3597Examples: >vim 3598let bufmodified = getbufvar(1, "&mod") 3599echo "todo myvar = " .. getbufvar("todo", "myvar") 3600< 3601]=] , 3602name ='getbufvar' , 3603params ={ { 'buf' , 'integer|string' } , { 'varname' , 'string' } , { 'def' , 'any' } } , 3604signature ='getbufvar({buf}, {varname} [, {def}])' , 3605see_lua ={ 3606'|nvim_buf_get_var()| or |vim.b| after resolving {buf} to a bufnr; option names use |nvim_get_option_value()| or |vim.bo|' , 3607} , 3608} , 3609getcellwidths ={ 3610desc =[=[ 3611Returns a |List| of cell widths of character ranges overridden 3612by |setcellwidths()|. The format is equal to the argument of 3613|setcellwidths()|. If no character ranges have their cell 3614widths overridden, an empty List is returned. 3615]=] , 3616name ='getcellwidths' , 3617params ={} , 3618signature ='getcellwidths()' , 3619} , 3620getchangelist ={ 3621args ={ 0 , 1 } , 3622base =1 , 3623desc =[=[ 3624Returns the |changelist| for the buffer {buf}. For the use 3625of {buf}, see |bufname()| above. If buffer {buf} doesn't 3626exist, an empty list is returned. 3627 3628The returned list contains two entries: a list with the change 3629locations and the current position in the list. Each 3630entry in the change list is a dictionary with the following 3631entries: 3632col column number 3633coladd column offset for 'virtualedit' 3634lnum line number 3635If buffer {buf} is the current buffer, then the current 3636position refers to the position in the list. For other 3637buffers, it is set to the length of the list. 3638 3639]=] , 3640name ='getchangelist' , 3641params ={ { 'buf' , 'integer|string' } } , 3642returns ='table[]' , 3643signature ='getchangelist([{buf}])' , 3644} , 3645getchar ={ 3646args ={ 0 , 2 } , 3647desc =[=[ 3648Get a single character from the user or input stream. 3649If {expr} is omitted or is -1, wait until a character is 3650available. 3651If {expr} is 0, only get a character when one is available. 3652Return zero otherwise. 3653If {expr} is 1, only check if a character is available, it is 3654not consumed. Return zero if no character available. 3655To always get a string, specify "number" as |FALSE| in {opts}. 3656 3657Without {expr} and when {expr} is 0 a whole character or 3658special key is returned. If it is a single character, the 3659result is a Number. Use |nr2char()| to convert it to a String. 3660Otherwise a String is returned with the encoded character. 3661For a special key it's a String with a sequence of bytes 3662starting with 0x80 (decimal: 128). This is the same value as 3663the String "\<Key>", e.g., "\<Left>". The returned value is 3664also a String when a modifier (shift, control, alt) was used 3665that is not included in the character. |keytrans()| can also 3666be used to convert a returned String into a readable form. 3667 3668When {expr} is 0 and Esc is typed, there will be a short delay 3669while Vim waits to see if this is the start of an escape 3670sequence. 3671 3672When {expr} is 1 only the first byte is returned. For a 3673one-byte character it is the character itself as a number. 3674Use |nr2char()| to convert it to a String. 3675 3676Use |getcharmod()| to obtain any additional modifiers. 3677 3678The optional argument {opts} is a Dict and supports the 3679following items: 3680 3681cursor A String specifying cursor behavior 3682when waiting for a character. 3683"hide": hide the cursor. 3684"keep": keep current cursor unchanged. 3685"msg": move cursor to message area. 3686(default: automagically decide 3687between "keep" and "msg") 3688 3689number If |TRUE|, return a Number when getting 3690a single character. 3691If |FALSE|, the return value is always 3692converted to a String, and an empty 3693String (instead of 0) is returned when 3694no character is available. 3695(default: |TRUE|) 3696 3697simplify If |TRUE|, include modifiers in the 3698character if possible. E.g., return 3699the same value for CTRL-I and <Tab>. 3700If |FALSE|, don't include modifiers in 3701the character. 3702(default: |TRUE|) 3703 3704When the user clicks a mouse button, the mouse event will be 3705returned. The position can then be found in |v:mouse_col|, 3706|v:mouse_lnum|, |v:mouse_winid| and |v:mouse_win|. 3707|getmousepos()| can also be used. Mouse move events will be 3708ignored. 3709This example positions the mouse as it would normally happen: >vim 3710let c = getchar() 3711if c == "\<LeftMouse>" && v:mouse_win > 0 3712exe v:mouse_win .. "wincmd w" 3713exe v:mouse_lnum 3714exe "normal " .. v:mouse_col .. "|" 3715endif 3716< 3717There is no prompt, you will somehow have to make clear to the 3718user that a character has to be typed. The screen is not 3719redrawn, e.g. when resizing the window. 3720 3721There is no mapping for the character. 3722Key codes are replaced, thus when the user presses the <Del> 3723key you get the code for the <Del> key, not the raw character 3724sequence. Examples: >vim 3725getchar() == "\<Del>" 3726getchar() == "\<S-Left>" 3727<This example redefines "f" to ignore case: >vim 3728nmap f :call FindChar()<CR> 3729function FindChar() 3730let c = nr2char(getchar()) 3731while col('.') < col('$') - 1 3732normal l 3733if getline('.')[col('.') - 1] ==? c 3734break 3735endif 3736endwhile 3737endfunction 3738< 3739]=] , 3740name ='getchar' , 3741params ={ { 'expr' , '-1|0|1' } , { 'opts' , 'table' } } , 3742returns ='integer|string' , 3743signature ='getchar([{expr} [, {opts}]])' , 3744} , 3745getcharmod ={ 3746desc =[=[ 3747Returns the state of the keyboard modifiers for the last 3748character obtained with |getchar()| or in another way. 3749These values are added together: 37502 shift 37514 control 37528 alt (meta) 375316 meta (when it's different from ALT) 375432 mouse double click 375564 mouse triple click 375696 mouse quadruple click (== 32 + 64) 3757128 command (Mac) or super 3758Only the modifiers that have not been included in the 3759character itself are obtained. Thus Shift-a results in "A" 3760without a modifier. Returns 0 if no modifiers are used. 3761]=] , 3762name ='getcharmod' , 3763params ={} , 3764returns ='integer' , 3765signature ='getcharmod()' , 3766} , 3767getcharpos ={ 3768args =1 , 3769base =1 , 3770desc =[=[ 3771Same as |getpos()|, except the column-number is 3772character-indexed (UTF-8) instead of byte-indexed. 3773 3774If |getpos()| returns |v:maxcol|, then getcharpos() returns 3775the index of the last character. 3776 3777Example: 3778With the cursor on '세' in line 5 with text "여보세요": >vim 3779getcharpos('.') returns [0, 5, 3, 0] 3780getpos('.') returns [0, 5, 7, 0] 3781< 3782]=] , 3783name ='getcharpos' , 3784params ={ { 'expr' , 'string' } } , 3785returns ='integer[]' , 3786signature ='getcharpos({expr})' , 3787} , 3788getcharsearch ={ 3789desc =[=[ 3790Return the current character search information as a {dict} 3791with the following entries: 3792 3793char character previously used for a character 3794search (|t|, |f|, |T|, or |F|); empty string 3795if no character search has been performed 3796forward direction of character search; 1 for forward, 37970 for backward 3798until type of character search; 1 for a |t| or |T| 3799character search, 0 for an |f| or |F| 3800character search 3801 3802This can be useful to always have |;| and |,| search 3803forward/backward regardless of the direction of the previous 3804character search: >vim 3805nnoremap <expr> ; getcharsearch().forward ? ';' : ',' 3806nnoremap <expr> , getcharsearch().forward ? ',' : ';' 3807<Also see |setcharsearch()|. 3808]=] , 3809name ='getcharsearch' , 3810params ={} , 3811returns ='{ char: string, forward: 1|0, until: 1|0 }' , 3812signature ='getcharsearch()' , 3813} , 3814getcharstr ={ 3815args ={ 0 , 2 } , 3816desc =[=[ 3817The same as |getchar()|, except that this always returns a 3818String, and "number" isn't allowed in {opts}. 3819]=] , 3820name ='getcharstr' , 3821params ={ { 'expr' , '-1|0|1' } , { 'opts' , 'table' } } , 3822returns ='string' , 3823signature ='getcharstr([{expr} [, {opts}]])' , 3824} , 3825getcmdcomplpat ={ 3826desc =[=[ 3827Return completion pattern of the current command-line. 3828Only works when the command line is being edited, thus 3829requires use of |c_CTRL-\_e| or |c_CTRL-R_=|. 3830Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|, 3831|getcmdprompt()|, |getcmdcompltype()| and |setcmdline()|. 3832Returns an empty string when completion is not defined. 3833]=] , 3834name ='getcmdcomplpat' , 3835params ={} , 3836returns ='string' , 3837signature ='getcmdcomplpat()' , 3838} , 3839getcmdcompltype ={ 3840desc =[=[ 3841Return the type of the current command-line completion. 3842Only works when the command line is being edited, thus 3843requires use of |c_CTRL-\_e| or |c_CTRL-R_=|. 3844See |:command-completion| for the return string. 3845Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|, 3846|getcmdprompt()|, |getcmdcomplpat()| and |setcmdline()|. 3847Returns an empty string when completion is not defined. 3848 3849To get the type of the command-line completion for a specified 3850string, use |getcompletiontype()|. 3851]=] , 3852name ='getcmdcompltype' , 3853params ={} , 3854returns ='string' , 3855signature ='getcmdcompltype()' , 3856} , 3857getcmdline ={ 3858desc =[=[ 3859Return the current command-line input. Only works when the 3860command line is being edited, thus requires use of 3861|c_CTRL-\_e| or |c_CTRL-R_=|. 3862Example: >vim 3863cmap <F7> <C-\>eescape(getcmdline(), ' \')<CR> 3864<Also see |getcmdtype()|, |getcmdpos()|, |setcmdpos()|, 3865|getcmdprompt()| and |setcmdline()|. 3866Returns an empty string when entering a password or using 3867|inputsecret()|. 3868]=] , 3869name ='getcmdline' , 3870params ={} , 3871returns ='string' , 3872signature ='getcmdline()' , 3873} , 3874getcmdpos ={ 3875desc =[=[ 3876Return the position of the cursor in the command line as a 3877byte count. The first column is 1. 3878Only works when editing the command line, thus requires use of 3879|c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping. 3880Returns 0 otherwise. 3881Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|, 3882|getcmdprompt()| and |setcmdline()|. 3883]=] , 3884name ='getcmdpos' , 3885params ={} , 3886returns ='integer' , 3887signature ='getcmdpos()' , 3888} , 3889getcmdprompt ={ 3890desc =[=[ 3891Return the current command-line prompt when using functions 3892like |input()| or |confirm()|. 3893Only works when the command line is being edited, thus 3894requires use of |c_CTRL-\_e| or |c_CTRL-R_=|. 3895Also see |getcmdtype()|, |getcmdline()|, |getcmdpos()|, 3896|setcmdpos()| and |setcmdline()|. 3897]=] , 3898name ='getcmdprompt' , 3899params ={} , 3900returns ='string' , 3901signature ='getcmdprompt()' , 3902} , 3903getcmdscreenpos ={ 3904desc =[=[ 3905Return the screen position of the cursor in the command line 3906as a byte count. The first column is 1. 3907Instead of |getcmdpos()|, it adds the prompt position. 3908Only works when editing the command line, thus requires use of 3909|c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping. 3910Returns 0 otherwise. 3911Also see |getcmdpos()|, |setcmdpos()|, |getcmdline()| and 3912|setcmdline()|. 3913]=] , 3914name ='getcmdscreenpos' , 3915params ={} , 3916returns ='integer' , 3917signature ='getcmdscreenpos()' , 3918} , 3919getcmdtype ={ 3920desc =[=[ 3921Return the current command-line type. Possible return values 3922are: 3923: normal Ex command 3924> debug mode command |debug-mode| 3925/ forward search command 3926? backward search command 3927@ |input()| command 3928`-` |:insert| or |:append| command 3929= |i_CTRL-R_=| 3930Only works when editing the command line, thus requires use of 3931|c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping. 3932Returns an empty string otherwise. 3933Also see |getcmdpos()|, |setcmdpos()| and |getcmdline()|. 3934]=] , 3935name ='getcmdtype' , 3936params ={} , 3937returns ="':'|'>'|'/'|'?'|'@'|'-'|'='|''" , 3938signature ='getcmdtype()' , 3939} , 3940getcmdwintype ={ 3941desc =[=[ 3942Return the current |command-line-window| type. Possible return 3943values are the same as |getcmdtype()|. Returns an empty string 3944when not in the command-line window. 3945]=] , 3946name ='getcmdwintype' , 3947params ={} , 3948returns ="':'|'>'|'/'|'?'|'@'|'-'|'='|''" , 3949signature ='getcmdwintype()' , 3950} , 3951getcompletion ={ 3952args ={ 2 , 3 } , 3953base =1 , 3954desc =[=[ 3955Return a list of command-line completion matches. The String 3956{type} argument specifies what for. The following completion 3957types are supported: 3958 3959arglist file names in argument list 3960augroup autocmd groups 3961buffer buffer names 3962breakpoint |:breakadd| and |:breakdel| suboptions 3963cmdline |cmdline-completion| result 3964color color schemes 3965command Ex command 3966compiler compilers 3967custom,{func} custom completion, defined via {func} 3968customlist,{func} custom completion, defined via {func} 3969diff_buffer |:diffget| and |:diffput| completion 3970dir directory names 3971dir_in_path directory names in 'cdpath' 3972environment environment variable names 3973event autocommand events 3974expression Vim expression 3975file file and directory names 3976file_in_path file and directory names in 'path' 3977filetype filetype names 'filetype' 3978filetypecmd |:filetype| suboptions 3979function function name 3980help help subjects 3981highlight highlight groups 3982history |:history| suboptions 3983keymap keyboard mappings 3984locale locale names (as output of locale -a) 3985mapclear buffer argument 3986mapping mapping name 3987menu menus 3988messages |:messages| suboptions 3989option options 3990packadd optional package |pack-add| names 3991retab |:retab| suboptions 3992runtime |:runtime| completion 3993scriptnames sourced script names |:scriptnames| 3994shellcmd Shell command 3995shellcmdline Shell command line with filename arguments 3996sign |:sign| suboptions 3997syntax syntax file names 'syntax' 3998syntime |:syntime| suboptions 3999tag tags 4000tag_listfiles tags, file names 4001user user names 4002var user variables 4003 4004If {pat} is an empty string, then all the matches are 4005returned. Otherwise only items matching {pat} are returned. 4006See |wildcards| for the use of special characters in {pat}. 4007 4008If the optional {filtered} flag is set to 1, then 'wildignore' 4009is applied to filter the results. Otherwise all the matches 4010are returned. The 'wildignorecase' option always applies. 4011 4012If the 'wildoptions' option contains "fuzzy", then fuzzy 4013matching is used to get the completion matches. Otherwise 4014regular expression matching is used. Thus this function 4015follows the user preference, what happens on the command line. 4016If you do not want this you can make 'wildoptions' empty 4017before calling getcompletion() and restore it afterwards. 4018 4019If {type} is "cmdline", then the |cmdline-completion| result is 4020returned. For example, to complete the possible values after 4021a ":call" command: >vim 4022echo getcompletion('call ', 'cmdline') 4023< 4024If there are no matches, an empty list is returned. An 4025invalid value for {type} produces an error. 4026 4027]=] , 4028name ='getcompletion' , 4029params ={ { 'pat' , 'string' } , { 'type' , 'string' } , { 'filtered' , 'boolean' } } , 4030returns ='string[]' , 4031signature ='getcompletion({pat}, {type} [, {filtered}])' , 4032} , 4033getcompletiontype ={ 4034args =1 , 4035base =1 , 4036desc =[=[ 4037Return the type of the command-line completion using {pat}. 4038When no corresponding completion type is found, an empty 4039string is returned. 4040To get the current command-line completion type, use 4041|getcmdcompltype()|. 4042]=] , 4043name ='getcompletiontype' , 4044params ={ { 'pat' , 'string' } } , 4045returns ='string' , 4046signature ='getcompletiontype({pat})' , 4047} , 4048getcurpos ={ 4049args ={ 0 , 1 } , 4050base =1 , 4051desc =[=[ 4052Get the position of the cursor. This is like getpos('.'), but 4053includes an extra "curswant" item in the list: 4054[0, lnum, col, off, curswant] ~ 4055The "curswant" number is the preferred column when moving the 4056cursor vertically. After |$| command it will be a very large 4057number equal to |v:maxcol|. Also see |getcursorcharpos()| and 4058|getpos()|. 4059The first "bufnum" item is always zero. The byte position of 4060the cursor is returned in "col". To get the character 4061position, use |getcursorcharpos()|. 4062 4063The optional {winid} (|window-number| or |window-ID|) specifies 4064the window. The last known cursor position is returned, this 4065may be invalid for the current value of the buffer if it is not 4066the current window. 4067If {winid} is invalid a list with zeroes is returned. 4068 4069This can be used to save and restore the cursor position: >vim 4070let save_cursor = getcurpos() 4071MoveTheCursorAround 4072call setpos('.', save_cursor) 4073<Note that this only works within the window. See 4074|winrestview()| for restoring more state. 4075 4076]=] , 4077name ='getcurpos' , 4078params ={ { 'winid' , 'integer' } } , 4079returns ='[integer, integer, integer, integer, integer]' , 4080signature ='getcurpos([{winid}])' , 4081see_lua ={ 4082'|nvim_win_get_cursor()|; return shape, 0-based column, and `curswant`/invalid-window semantics differ' , 4083} , 4084} , 4085getcursorcharpos ={ 4086args ={ 0 , 1 } , 4087base =1 , 4088desc =[=[ 4089Same as |getcurpos()| but the column number in the returned 4090List is a character index instead of a byte index. 4091 4092Example: 4093With the cursor on '보' in line 3 with text "여보세요": >vim 4094getcursorcharpos() " returns [0, 3, 2, 0, 3] 4095getcurpos() " returns [0, 3, 4, 0, 3] 4096< 4097]=] , 4098name ='getcursorcharpos' , 4099params ={ { 'winid' , 'integer' } } , 4100signature ='getcursorcharpos([{winid}])' , 4101} , 4102getcwd ={ 4103args ={ 0 , 3 } , 4104base =1 , 4105desc =[=[ 4106Without arguments, returns the effective |current-directory|. 4107With {winnr} (|window-number| or |window-ID|), {tabnr} or 4108{bufnr} the working directory of that scope is returned, 4109ignoring 'autochdir'. 4110 4111- If {winnr} is -1: gets the tabpage directory. 4112- If {winnr} and {tabnr} are both -1: gets the global 4113directory. 4114- Note: Vim returns an empty string when {tabnr} is -1. 4115- If {bufnr} is given: gets the buffer-local directory. 4116({winnr} and {tabnr} must be -1.) 4117- An argument may be -1 only if preceding args are -1. *E5001* 4118 4119Tabs, windows and buffers are identified by their respective 4120numbers, 0 means current tab/window/buffer. Missing {tabnr} 4121implies 0 (missing {bufnr} does not; see below). Thus the 4122following are equivalent: >vim 4123getcwd(0) 4124getcwd(0, 0) 4125< 4126Each form reports its own scope or "wider", so e.g. {winnr} 4127never reports a buffer-local directory. The {bufnr} form 4128falls back to the global directory, because a buffer belongs 4129to no particular window or tabpage. 4130 4131Examples: >vim 4132getcwd(-1, -1, 0) " Get current buffer's directory 4133getcwd(-1, -1, 3) " Get directory of buffer 3 4134getcwd(-1, -1, -1) " Get global directory 4135getcwd(-1, -1) " Get global directory 4136< 4137]=] , 4138name ='getcwd' , 4139params ={ { 'winnr' , 'integer' } , { 'tabnr' , 'integer' } , { 'bufnr' , 'integer' } } , 4140returns ='string' , 4141signature ='getcwd([{winnr} [, {tabnr} [, {bufnr}]]])' , 4142tags ={ 'E5000' , 'E5002' , 'E5006' , 'E5007' } , 4143} , 4144getenv ={ 4145args =1 , 4146base =1 , 4147desc =[=[ 4148Return the value of environment variable {name}. The {name} 4149argument is a string, without a leading '$'. Example: >vim 4150myHome = getenv('HOME') 4151 4152<When the variable does not exist |v:null| is returned. That 4153is different from a variable set to an empty string. 4154See also |expr-env|. 4155 4156]=] , 4157name ='getenv' , 4158params ={ { 'name' , 'string' } } , 4159returns ='string' , 4160signature ='getenv({name})' , 4161see_lua ={ '|vim.env|' } , 4162} , 4163getfontname ={ 4164args ={ 0 , 1 } , 4165desc =[=[ 4166Without an argument returns the name of the normal font being 4167used. Like what is used for the Normal highlight group 4168|hl-Normal|. 4169With an argument a check is done whether String {name} is a 4170valid font name. If not then an empty string is returned. 4171Otherwise the actual font name is returned, or {name} if the 4172GUI does not support obtaining the real name. 4173Only works when the GUI is running, thus not in your vimrc or 4174gvimrc file. Use the |GUIEnter| autocommand to use this 4175function just after the GUI has started. 4176]=] , 4177name ='getfontname' , 4178params ={ { 'name' , 'string' } } , 4179returns ='string' , 4180signature ='getfontname([{name}])' , 4181} , 4182getfperm ={ 4183args =1 , 4184base =1 , 4185desc =[=[ 4186Returns the file permissions of the given file {fname} as a 4187String. If {fname} does not exist or its directory cannot be 4188read, an empty string is returned. 4189The result is of the form "rwxrwxrwx", where each group of 4190"rwx" flags represent, in turn, the permissions of the owner 4191of the file, the group the file belongs to, and other users. 4192If a user does not have a given permission the flag for this 4193is replaced with the string "-". Examples: >vim 4194echo getfperm("/etc/passwd") 4195echo getfperm(expand("~/.config/nvim/init.vim")) 4196<This will hopefully (from a security point of view) display 4197the string "rw-r--r--" or even "rw-------". 4198 4199For setting permissions use |setfperm()|. 4200]=] , 4201fast =true , 4202name ='getfperm' , 4203params ={ { 'fname' , 'string' } } , 4204returns ='string' , 4205signature ='getfperm({fname})' , 4206see_lua ={ '|uv.fs_stat()|' } , 4207} , 4208getfsize ={ 4209args =1 , 4210base =1 , 4211desc =[=[ 4212Returns the size in bytes of the given file {fname}. 4213If {fname} is a directory, 0 is returned. 4214If the file {fname} can't be found, -1 is returned. 4215If the size of {fname} is too big to fit in a Number then -2 4216is returned. 4217 4218]=] , 4219fast =true , 4220name ='getfsize' , 4221params ={ { 'fname' , 'string' } } , 4222returns ='integer' , 4223signature ='getfsize({fname})' , 4224see_lua ={ '|uv.fs_stat()|' } , 4225} , 4226getftime ={ 4227args =1 , 4228base =1 , 4229desc =[=[ 4230Returns the last modification time ("mtime") of file {fname}. 4231The value is measured as seconds since 1st Jan 1970, and may 4232be passed to |strftime()|. See also 4233|localtime()| and |strftime()|. 4234If the file {fname} can't be found -1 is returned. 4235 4236]=] , 4237fast =true , 4238name ='getftime' , 4239params ={ { 'fname' , 'string' } } , 4240returns ='integer' , 4241signature ='getftime({fname})' , 4242see_lua ={ '|uv.fs_stat()|' } , 4243} , 4244getftype ={ 4245args =1 , 4246base =1 , 4247desc =[=[ 4248Returns a description of the type of file {fname} as a 4249String. If {fname} does not exist an empty string is 4250returned. 4251Here is a table over different kinds of files and their 4252results: 4253Normal file "file" 4254Directory "dir" 4255Symbolic link "link" 4256Block device "bdev" 4257Character device "cdev" 4258Socket "socket" 4259FIFO "fifo" 4260All other "other" 4261Example: >vim 4262getftype("/home") 4263<Note that a type such as "link" will only be returned on 4264systems that support it. On some systems only "dir" and 4265"file" are returned. 4266 4267]=] , 4268fast =true , 4269name ='getftype' , 4270params ={ { 'fname' , 'string' } } , 4271returns ="'file'|'dir'|'link'|'bdev'|'cdev'|'socket'|'fifo'|'other'" , 4272signature ='getftype({fname})' , 4273see_lua ={ '|uv.fs_stat()|' } , 4274} , 4275getjumplist ={ 4276args ={ 0 , 2 } , 4277base =1 , 4278desc =[=[ 4279Returns the |jumplist| for the specified window. 4280 4281Without arguments use the current window. 4282With {winnr} (|window-number| or |window-ID|) only use this 4283window in the current tabpage. 4284With {winnr} and {tabnr} use the window in the specified tab 4285page. If {winnr} or {tabnr} is invalid, an empty list is 4286returned. 4287 4288The returned list contains two entries: a list with the jump 4289locations and the last used jump position number in the list. 4290Each entry in the jump location list is a dictionary with 4291the following entries: 4292bufnr buffer number 4293col column number 4294coladd column offset for 'virtualedit' 4295filename filename if available 4296lnum line number 4297 4298]=] , 4299name ='getjumplist' , 4300params ={ { 'winnr' , 'integer' } , { 'tabnr' , 'integer' } } , 4301signature ='getjumplist([{winnr} [, {tabnr}]])' , 4302returns ='vim.fn.getjumplist.ret' , 4303see_lua ={ 4304'|nvim_get_context()| for current jump history; window/tab arguments and return shape differ' , 4305} , 4306} , 4307getline ={ 4308args ={ 1 , 2 } , 4309base =1 , 4310desc =[=[ 4311Without {end} the result is a String, which is line {lnum} 4312from the current buffer. Example: >vim 4313getline(1) 4314<When {lnum} is a String that doesn't start with a 4315digit, |line()| is called to translate the String into a Number. 4316To get the line under the cursor: >vim 4317getline(".") 4318<When {lnum} is a number smaller than 1 or bigger than the 4319number of lines in the buffer, an empty string is returned. 4320 4321]=] , 4322name ='getline' , 4323params ={ { 'lnum' , 'integer|string' } } , 4324signature ='getline({lnum})' , 4325returns ='string' , 4326see_lua ={ '|nvim_get_current_line()|' , '|nvim_buf_get_lines()|' } , 4327} , 4328getline__1 ={ 4329args ={ 2 } , 4330base =1 , 4331desc =[=[ 4332When {end} is given the result is a |List| where each item is 4333a line from the current buffer in the range {lnum} to {end}, 4334including line {end}. 4335{end} is used in the same way as {lnum}. 4336Non-existing lines are silently omitted. 4337When {end} is before {lnum} an empty |List| is returned. 4338Example: >vim 4339let start = line('.') 4340let end = search("^$") - 1 4341let lines = getline(start, end) 4342 4343<To get lines from another buffer see |getbufline()| and 4344|getbufoneline()| 4345]=] , 4346name ='getline' , 4347params ={ { 'lnum' , 'integer|string' } , { 'end' , 'integer|string' } } , 4348signature ='getline({lnum}, {end})' , 4349returns ='string[]' , 4350see_lua ={ '|nvim_buf_get_lines()|' } , 4351} , 4352getloclist ={ 4353args ={ 1 , 2 } , 4354desc =[=[ 4355Returns a |List| with all the entries in the location list for 4356window {nr} (|window-number| or |window-ID|). 4357When {nr} is zero the current window is used. 4358 4359For a location list window, the displayed location list is 4360returned. For an invalid {nr}, an empty list is returned. 4361Otherwise, same as |getqflist()|. 4362]=] , 4363name ='getloclist' , 4364params ={ { 'nr' , 'integer' } } , 4365returns ='vim.fn.getqflist.ret.item[]' , 4366signature ='getloclist({nr})' , 4367} , 4368getloclist__1 ={ 4369args ={ 2 } , 4370desc =[=[ 4371If the optional {what} dictionary argument is supplied, then 4372returns the items listed in {what} as a dictionary. Refer to 4373|getqflist()| for the supported items in {what}. 4374 4375In addition to the items supported by |getqflist()| in {what}, 4376the following item is supported by |getloclist()|: 4377 4378filewinid id of the window used to display files 4379from the location list. This field is 4380applicable only when called from a 4381location list window. See 4382|location-list-file-window| for more 4383details. 4384 4385Returns a |Dictionary| with default values if there is no 4386location list for the window {nr}. 4387Returns an empty Dictionary if window {nr} does not exist. 4388 4389Examples (See also |getqflist-examples|): >vim 4390echo getloclist(3, {'all': 0}) 4391echo getloclist(5, {'filewinid': 0}) 4392< 4393]=] , 4394name ='getloclist' , 4395params ={ { 'nr' , 'integer' } , { 'what' , 'vim.fn.getloclist.what' } } , 4396returns ='vim.fn.getloclist.ret' , 4397signature ='getloclist({nr}, {what})' , 4398} , 4399getmarklist ={ 4400args ={ 0 , 1 } , 4401base =1 , 4402desc =[=[ 4403Without the {buf} argument returns a |List| with information 4404about all the global marks. |mark| 4405 4406If the optional {buf} argument is specified, returns the 4407local marks defined in buffer {buf}. For the use of {buf}, 4408see |bufname()|. If {buf} is invalid, an empty list is 4409returned. For a |prompt-buffer| the result includes the 4410|':| mark. 4411 4412Each item in the returned List is a |Dict| with the following: 4413mark name of the mark prefixed by "'" 4414pos a |List| with the position of the mark: 4415[bufnum, lnum, col, off] 4416Refer to |getpos()| for more information. 4417file file name 4418 4419Refer to |getpos()| for getting information about a specific 4420mark. 4421 4422]=] , 4423name ='getmarklist' , 4424params ={ { 'buf' , 'integer?' } } , 4425signature ='getmarklist([{buf}])' , 4426returns ='vim.fn.getmarklist.ret.item[]' , 4427} , 4428getmatches ={ 4429args ={ 0 , 1 } , 4430desc =[=[ 4431Returns a |List| with all matches previously defined for the 4432current window by |matchadd()| and the |:match| commands. 4433|getmatches()| is useful in combination with |setmatches()|, 4434as |setmatches()| can restore a list of matches saved by 4435|getmatches()|. 4436If {win} is specified, use this |window-number| or |window-ID| 4437instead of the current window. If {win} is invalid, an empty 4438list is returned. 4439Example: >vim 4440echo getmatches() 4441< > 4442[{"group": "MyGroup1", "pattern": "TODO", 4443"priority": 10, "id": 1}, {"group": "MyGroup2", 4444"pattern": "FIXME", "priority": 10, "id": 2}] 4445< >vim 4446let m = getmatches() 4447call clearmatches() 4448echo getmatches() 4449< > 4450[] 4451< >vim 4452call setmatches(m) 4453echo getmatches() 4454< > 4455[{"group": "MyGroup1", "pattern": "TODO", 4456"priority": 10, "id": 1}, {"group": "MyGroup2", 4457"pattern": "FIXME", "priority": 10, "id": 2}] 4458< >vim 4459unlet m 4460< 4461]=] , 4462name ='getmatches' , 4463params ={ { 'win' , 'integer' } } , 4464returns ='vim.fn.getmatches.ret.item[]' , 4465signature ='getmatches([{win}])' , 4466} , 4467getmousepos ={ 4468desc =[=[ 4469Returns a |Dictionary| with the last known position of the 4470mouse. This can be used in a mapping for a mouse click. The 4471items are: 4472screenrow screen row 4473screencol screen column 4474winid Window ID of the click 4475winrow row inside "winid" 4476wincol column inside "winid" 4477line text line inside "winid" 4478column text column inside "winid" 4479coladd offset (in screen columns) from the 4480start of the clicked char 4481All numbers are 1-based. 4482 4483If not over a window, e.g. when in the command line, then only 4484"screenrow" and "screencol" are valid, the others are zero. 4485 4486When on the status line below a window or the vertical 4487separator right of a window, the "line" and "column" values 4488are zero. 4489 4490When the position is after the text then "column" is the 4491length of the text in bytes plus one. 4492 4493If the mouse is over a focusable floating window then that 4494window is used. 4495 4496When using |getchar()| the Vim variables |v:mouse_lnum|, 4497|v:mouse_col| and |v:mouse_winid| also provide these values. 4498]=] , 4499name ='getmousepos' , 4500params ={} , 4501signature ='getmousepos()' , 4502returns ='vim.fn.getmousepos.ret' , 4503} , 4504getpid ={ 4505desc =[=[ 4506Return a Number which is the process ID of the Vim process. 4507This is a unique number, until Vim exits. 4508]=] , 4509fast =true , 4510name ='getpid' , 4511params ={} , 4512returns ='integer' , 4513signature ='getpid()' , 4514see_lua ={ '|uv.os_getpid()|' } , 4515} , 4516getpos ={ 4517args =1 , 4518base =1 , 4519desc =[=[ 4520Gets a position, where {expr} is one of: 4521. Cursor position. 4522$ Last line in the current buffer. 4523'x Position of mark x (if the mark is not set, 0 is 4524returned for all values). 4525w0 First line visible in current window (one if the 4526display isn't updated, e.g. in |silent-mode|). 4527w$ Last line visible in current window (this is one 4528less than "w0" if no lines are visible). 4529v End of the current Visual selection (unlike |'<| 4530|'>| which give the previous, not current, Visual 4531selection), or the cursor position if not in Visual 4532mode. 4533 4534To get the current selected region: >vim 4535let region = getregionpos(getpos('v'), getpos('.')) 4536< 4537Explanation: in Visual mode "v" and "." complement each 4538other. While "." refers to the cursor position, "v" 4539refers to where |v_o| would move the cursor. So you can 4540use "v" and "." together to get the selected region. 4541 4542Note that if a mark in another file is used, the line number 4543applies to that buffer. 4544 4545The result is a |List| with four numbers: 4546[bufnum, lnum, col, off] 4547"bufnum" is zero, unless a mark like '0 or 'A is used, then it 4548is the buffer number of the mark. 4549"lnum" and "col" are the position in the buffer. The first 4550column is 1. 4551The "off" number is zero, unless 'virtualedit' is used. Then 4552it is the offset in screen columns from the start of the 4553character. E.g., a position within a <Tab> or after the last 4554character. 4555 4556For getting the cursor position see |getcurpos()|. 4557The column number in the returned List is the byte position 4558within the line. To get the character position in the line, 4559use |getcharpos()|. 4560 4561The visual marks |'<| and |'>| refer to the beginning and end 4562of the visual selection relative to the buffer. Note that 4563this differs from |setpos()|, where they are relative to the 4564cursor position. 4565 4566Note that for '< and '> Visual mode matters: when it is "V" 4567(visual line mode) the column of '< is zero and the column of 4568'> is a large number equal to |v:maxcol|. 4569A very large column number equal to |v:maxcol| can be returned, 4570in which case it means "after the end of the line". 4571If {expr} is invalid, returns a list with all zeros. 4572 4573This can be used to save and restore the position of a mark: >vim 4574let save_a_mark = getpos("'a") 4575" ... 4576call setpos("'a", save_a_mark) 4577< 4578Also see |getcharpos()|, |getcurpos()| and |setpos()|. 4579 4580]=] , 4581name ='getpos' , 4582params ={ { 'expr' , 'string' } } , 4583returns ='[integer, integer, integer, integer]' , 4584signature ='getpos({expr})' , 4585see_lua ={ 4586'|nvim_win_get_cursor()| for "." or |nvim_buf_get_mark()| for marks; return shape, `off`, and special-position semantics differ' , 4587} , 4588} , 4589getqflist ={ 4590args ={ 0 , 1 } , 4591desc =[=[ 4592Returns a |List| with all the current quickfix errors. Each 4593list item is a dictionary with these entries: 4594bufnr number of buffer that has the file name, use 4595|bufname()| to get the name 4596module module name 4597lnum line number in the buffer (first line is 1) 4598end_lnum 4599end of line number if the item is multiline 4600col column number (first column is 1) 4601end_col end of column number if the item has range 4602vcol |TRUE|: "col" is visual column 4603|FALSE|: "col" is byte index 4604nr error number 4605pattern search pattern used to locate the error 4606text description of the error 4607type type of the error, 'E', '1', etc. 4608valid |TRUE|: recognized error message 4609user_data 4610any type. This entry is present only when 4611user data was set for this item. 4612 4613When there is no error list or it's empty, an empty list is 4614returned. Quickfix list entries with a non-existing buffer 4615number are returned with "bufnr" set to zero (Note: some 4616functions accept buffer number zero for the alternate buffer, 4617you may need to explicitly check for zero). 4618 4619Useful application: Find pattern matches in multiple files and 4620do something with them: >vim 4621vimgrep /theword/jg *.c 4622for d in getqflist() 4623echo bufname(d.bufnr) ':' d.lnum '=' d.text 4624endfor 4625< 4626]=] , 4627name ='getqflist' , 4628params ={} , 4629returns ='vim.fn.getqflist.ret.item[]' , 4630signature ='getqflist()' , 4631} , 4632getqflist__1 ={ 4633args ={ 1 } , 4634desc =[=[ 4635If the optional {what} dictionary argument is supplied, then 4636returns only the items listed in {what} as a dictionary. The 4637following string items are supported in {what}: 4638changedtick get the total number of changes made 4639to the list |quickfix-changedtick| 4640context get the |quickfix-context| 4641efm errorformat to use when parsing "lines". If 4642not present, then the 'errorformat' option 4643value is used. 4644id get information for the quickfix list with 4645|quickfix-ID|; zero means the id for the 4646current list or the list specified by "nr" 4647idx get information for the quickfix entry at this 4648index in the list specified by "id" or "nr". 4649If set to zero, then uses the current entry. 4650See |quickfix-index| 4651items quickfix list entries 4652lines parse a list of lines using 'efm' and return 4653the resulting entries. Only a |List| type is 4654accepted. The current quickfix list is not 4655modified. See |quickfix-parse|. 4656nr get information for this quickfix list; zero 4657means the current quickfix list and "$" means 4658the last quickfix list 4659qfbufnr number of the buffer displayed in the quickfix 4660window. Returns 0 if the quickfix buffer is 4661not present. See |quickfix-buffer|. 4662quickfixtextfunc 4663function to get the text to display in the 4664quickfix window. Returns an empty string if 4665this function is not set for the list. See 4666|quickfix-window-function|. 4667size number of entries in the quickfix list 4668title get the list title |quickfix-title| 4669winid get the quickfix |window-ID| 4670all all of the above quickfix properties 4671Non-string items in {what} are ignored. To get the value of a 4672particular item, set it to zero. 4673If "nr" is not present then the current quickfix list is used. 4674If both "nr" and a non-zero "id" are specified, then the list 4675specified by "id" is used. 4676To get the number of lists in the quickfix stack, set "nr" to 4677"$" in {what}. The "nr" value in the returned dictionary 4678contains the quickfix stack size. 4679When "lines" is specified, all the other items except "efm" 4680are ignored. The returned dictionary contains the entry 4681"items" with the list of entries. 4682 4683The returned dictionary contains the following entries: 4684changedtick total number of changes made to the 4685list |quickfix-changedtick| 4686context quickfix list context. See |quickfix-context| 4687If not present, set to "". 4688id quickfix list ID |quickfix-ID|. If not 4689present, set to 0. 4690idx index of the quickfix entry in the list. If 4691not present, set to 0. 4692items quickfix list entries. If not present, set to 4693an empty list. 4694nr quickfix list number. If not present, set to 46950 4696qfbufnr number of the buffer displayed in the quickfix 4697window. If not present, set to 0. 4698quickfixtextfunc 4699'quickfixtextfunc' setting of the list. If 4700not present, set to "". 4701size number of entries in the quickfix list. If 4702not present, set to 0. 4703title quickfix list title text. If not present, set 4704to "". 4705winid quickfix |window-ID|. If not present, set to 0 4706 4707Examples (See also |getqflist-examples|): >vim 4708echo getqflist({'all': 1}) 4709echo getqflist({'nr': 2, 'title': 1}) 4710echo getqflist({'lines' : ["F1:10:L10"]}) 4711< 4712]=] , 4713name ='getqflist' , 4714params ={ { 'what' , 'vim.fn.getqflist.what' } } , 4715returns ='vim.fn.getqflist.ret' , 4716signature ='getqflist({what})' , 4717} , 4718getreg ={ 4719args ={ 0 , 3 } , 4720base =1 , 4721desc =[=[ 4722Returns the contents of register {regname} as a String. 4723Example: >vim 4724let cliptext = getreg('*') 4725<When register {regname} was not set the result is an empty 4726string. 4727The {regname} argument must be a string. 4728 4729getreg('=') returns the last evaluated value of the expression 4730register. (For use in maps.) 4731getreg('=', 1) returns the expression itself, so that it can 4732be restored with |setreg()|. For other registers the extra 4733argument is ignored, thus you can always give it. 4734 4735If {list} is present and |TRUE|, the result type is changed 4736to |List|. Each list item is one text line. Use it if you care 4737about zero bytes possibly present inside register: without 4738third argument both NLs and zero bytes are represented as NLs 4739(see |NL-used-for-Nul|). 4740When the register was not set an empty list is returned. 4741 4742If {regname} is not specified, |v:register| is used. 4743 4744]=] , 4745name ='getreg' , 4746params ={ { 'regname' , 'string' } , { 'expr' , 'any' } , { 'list' , 'nil|false' } } , 4747signature ='getreg([{regname} [, 1 [, {list}]]])' , 4748returns ='string' , 4749} , 4750getreg__1 ={ 4751args ={ 3 } , 4752base =1 , 4753name ='getreg' , 4754params ={ { 'regname' , 'string' } , { 'expr' , 'any' } , { 'list' , 'true|number|string|table' } } , 4755returns ='string[]' , 4756} , 4757getreginfo ={ 4758args ={ 0 , 1 } , 4759base =1 , 4760desc =[=[ 4761Returns detailed information about register {regname} as a 4762Dictionary with the following entries: 4763regcontents List of lines contained in register 4764{regname}, like 4765getreg({regname}, 1, 1). 4766regtype the type of register {regname}, as in 4767|getregtype()|. 4768isunnamed Boolean flag, v:true if this register 4769is currently pointed to by the unnamed 4770register. 4771points_to for the unnamed register, gives the 4772single letter name of the register 4773currently pointed to (see |quotequote|). 4774For example, after deleting a line 4775with `dd`, this field will be "1", 4776which is the register that got the 4777deleted text. 4778 4779The {regname} argument is a string. If {regname} is invalid 4780or not set, an empty Dictionary will be returned. 4781If {regname} is not specified, |v:register| is used. 4782The returned Dictionary can be passed to |setreg()|. 4783 4784]=] , 4785name ='getreginfo' , 4786params ={ { 'regname' , 'string' } } , 4787returns ='table' , 4788signature ='getreginfo([{regname}])' , 4789} , 4790getregion ={ 4791args ={ 2 , 3 } , 4792base =1 , 4793desc =[=[ 4794Returns the list of strings from {pos1} to {pos2} from a 4795buffer. 4796 4797{pos1} and {pos2} must both be |List|s with four numbers. 4798See |getpos()| for the format of the list. It's possible 4799to specify positions from a different buffer, but please 4800note the limitations at |getregion-notes|. 4801 4802The optional argument {opts} is a Dict and supports the 4803following items: 4804 4805type Specify the region's selection type. 4806See |getregtype()| for possible values, 4807except that the width can be omitted 4808and an empty string cannot be used. 4809(default: "v") 4810 4811exclusive If |TRUE|, use exclusive selection 4812for the end position. 4813(default: follow 'selection') 4814 4815You can get the last selection type by |visualmode()|. 4816If Visual mode is active, use |mode()| to get the Visual mode 4817(e.g., in a |:vmap|). 4818This function is useful to get text starting and ending in 4819different columns, such as a |charwise-visual| selection. 4820 4821*getregion-notes* 4822Note that: 4823- Order of {pos1} and {pos2} doesn't matter, it will always 4824return content from the upper left position to the lower 4825right position. 4826- If 'virtualedit' is enabled and the region is past the end 4827of the lines, resulting lines are padded with spaces. 4828- If the region is blockwise and it starts or ends in the 4829middle of a multi-cell character, it is not included but 4830its selected part is substituted with spaces. 4831- If {pos1} and {pos2} are not in the same buffer, an empty 4832list is returned. 4833- {pos1} and {pos2} must belong to a |bufloaded()| buffer. 4834- It is evaluated in current window context, which makes a 4835difference if the buffer is displayed in a window with 4836different 'virtualedit' or 'list' values. 4837- When specifying an exclusive selection and {pos1} and {pos2} 4838are equal, the returned list contains a single character as 4839if selection is inclusive, to match the behavior of an empty 4840exclusive selection in Visual mode. 4841 4842Examples: >vim 4843xnoremap <CR> 4844\ <Cmd>echom getregion( 4845\ getpos('v'), getpos('.'), #{ type: mode() })<CR> 4846< 4847]=] , 4848name ='getregion' , 4849params ={ 4850{ 'pos1' , '[integer, integer, integer, integer]' } , 4851{ 'pos2' , '[integer, integer, integer, integer]' } , 4852{ 'opts' , '{type?:string, exclusive?:boolean}' } , 4853} , 4854returns ='string[]' , 4855signature ='getregion({pos1}, {pos2} [, {opts}])' , 4856} , 4857getregionpos ={ 4858args ={ 2 , 3 } , 4859base =1 , 4860desc =[=[ 4861Same as |getregion()|, but returns a list of positions 4862describing the buffer text segments bound by {pos1} and 4863{pos2}. 4864The segments are a pair of positions for every line: > 4865[[{startpos}, {endpos}], ...] 4866< 4867The position is a |List| with four numbers: 4868[bufnum, lnum, col, off] 4869"bufnum" is the buffer number. 4870"lnum" and "col" are the position in the buffer. The first 4871column is 1. 4872If the "off" number of a starting position is non-zero, it is 4873the offset in screen columns from the start of the character. 4874E.g., a position within a <Tab> or after the last character. 4875If the "off" number of an ending position is non-zero, it is 4876the offset of the character's first cell not included in the 4877selection, otherwise all its cells are included. 4878 4879To get the current visual selection: >vim 4880let region = getregionpos(getpos('v'), getpos('.')) 4881< 4882The {opts} Dict supports the following items: 4883 4884type See |getregion()|. 4885 4886exclusive See |getregion()|. 4887 4888eol If |TRUE|, indicate positions beyond 4889the end of a line with "col" values 4890one more than the length of the line. 4891If |FALSE|, positions are limited 4892within their lines, and if a line is 4893empty or the selection is entirely 4894beyond the end of a line, a "col" 4895value of 0 is used for both positions. 4896(default: |FALSE|) 4897 4898bounds If |TRUE|, return only the outer 4899bounds of the region as a single 4900pair: > 4901[[{startpos}, {endpos}]] 4902< {startpos} is the start position on 4903the first line of the region and 4904{endpos} the end position on its last 4905line. The lines in between are not 4906visited, which is much faster for a 4907large region. 4908(default: |FALSE|) 4909 4910Using "bounds" with the same {opts} is equivalent to taking 4911the outer positions of the full result: >vim 4912let full = getregionpos(pos1, pos2, opts) 4913let bounds = [[full[0][0], full[-1][1]]] 4914<When the full result is empty, e.g. because {pos1} and {pos2} 4915are in different buffers, the result is empty as well. 4916Note that the two positions then come from different lines, so 4917they describe a diagonal of the region and not its shape. For 4918a blockwise region they are the start of the first line and 4919the end of the last line, not the corners of the block. 4920Likewise, when the first line is empty and "eol" is |FALSE|, 4921{startpos} has a "col" of 0 while {endpos} may not. 4922]=] , 4923name ='getregionpos' , 4924params ={ 4925{ 'pos1' , '[integer, integer, integer, integer]' } , 4926{ 'pos2' , '[integer, integer, integer, integer]' } , 4927{ 'opts' , '{type?:string, exclusive?:boolean, eol?:boolean, bounds?:boolean}' } , 4928} , 4929returns ='[ [integer, integer, integer, integer], [integer, integer, integer, integer] ][]' , 4930signature ='getregionpos({pos1}, {pos2} [, {opts}])' , 4931} , 4932getregtype ={ 4933args ={ 0 , 1 } , 4934base =1 , 4935desc =[=[ 4936Returns the type of register {regname} as a String. 4937The value will be one of: 4938"v" for |charwise| text 4939"V" for |linewise| text 4940"<CTRL-V>{width}" for |blockwise-visual| text 4941"" for an empty or unknown register 4942<CTRL-V> is one character with value 0x16. 4943The {regname} argument is a string. If {regname} is not 4944specified, |v:register| is used. 4945 4946]=] , 4947name ='getregtype' , 4948params ={ { 'regname' , 'string' } } , 4949returns ='string' , 4950signature ='getregtype([{regname}])' , 4951} , 4952getscriptinfo ={ 4953args ={ 0 , 1 } , 4954desc =[=[ 4955Returns a |List| with information about all the sourced Vim 4956scripts in the order they were sourced, like what 4957`:scriptnames` shows. 4958 4959The optional Dict argument {opts} supports the following 4960optional items: 4961name Script name match pattern. If specified, 4962and "sid" is not specified, information about 4963scripts with a name that match the pattern 4964"name" are returned. 4965sid Script ID |<SID>|. If specified, only 4966information about the script with ID "sid" is 4967returned and "name" is ignored. 4968 4969Each item in the returned List is a |Dict| with the following 4970items: 4971autoload Always set to FALSE. 4972functions List of script-local function names defined in 4973the script. Present only when a particular 4974script is specified using the "sid" item in 4975{opts}. 4976name Vim script file name. 4977sid Script ID |<SID>|. 4978variables A dictionary with the script-local variables. 4979Present only when a particular script is 4980specified using the "sid" item in {opts}. 4981Note that this is a copy, the value of 4982script-local variables cannot be changed using 4983this dictionary. 4984version Vim script version, always 1 4985 4986Examples: >vim 4987echo getscriptinfo({'name': 'myscript'}) 4988echo getscriptinfo({'sid': 15})[0].variables 4989< 4990]=] , 4991name ='getscriptinfo' , 4992params ={ { 'opts' , 'table' } } , 4993returns ='vim.fn.getscriptinfo.ret[]' , 4994signature ='getscriptinfo([{opts}])' , 4995} , 4996getstacktrace ={ 4997args =0 , 4998desc =[=[ 4999Returns the current stack trace of Vim scripts. 5000Stack trace is a |List|, of which each item is a |Dictionary| 5001with the following items: 5002funcref The funcref if the stack is at a function, 5003otherwise this item is omitted. 5004event The string of the event description if the 5005stack is at an autocmd event, otherwise this 5006item is omitted. 5007lnum The line number in the script on the stack. 5008filepath The file path of the script on the stack. 5009]=] , 5010name ='getstacktrace' , 5011params ={} , 5012returns ='table[]' , 5013signature ='getstacktrace()' , 5014see_lua ={ '|debug.traceback()|' } , 5015} , 5016gettabinfo ={ 5017args ={ 0 , 1 } , 5018base =1 , 5019desc =[=[ 5020If {tabnr} is not specified, then information about all the 5021tabpages is returned as a |List|. Each List item is a 5022|Dictionary|. Otherwise, {tabnr} specifies the tabpage 5023number and information about that one is returned. If the tab 5024page does not exist an empty List is returned. 5025 5026Each List item is a |Dictionary| with the following entries: 5027tabnr |tabpage-number| 5028variables a reference to the dictionary with 5029tabpage-local variables 5030windows List of |window-ID|s in the tabpage. 5031 5032]=] , 5033name ='gettabinfo' , 5034params ={ { 'tabnr' , 'integer' } } , 5035signature ='gettabinfo([{tabnr}])' , 5036} , 5037gettabvar ={ 5038args ={ 2 , 3 } , 5039base =1 , 5040desc =[=[ 5041Get the value of a tab-local variable {varname} in tabpage 5042{tabnr}. |t:var| 5043Tabs are numbered starting with one. 5044The {varname} argument is a string. When {varname} is empty a 5045dictionary with all tab-local variables is returned. 5046Note that the name without "t:" must be used. 5047When the tab or variable doesn't exist {def} or an empty 5048string is returned, there is no error message. 5049 5050]=] , 5051name ='gettabvar' , 5052params ={ { 'tabnr' , 'integer' } , { 'varname' , 'string' } , { 'def' , 'any' } } , 5053signature ='gettabvar({tabnr}, {varname} [, {def}])' , 5054see_lua ={ '|nvim_tabpage_get_var()|' , '|vim.t|' } , 5055} , 5056gettabwinvar ={ 5057args ={ 3 , 4 } , 5058base =1 , 5059desc =[=[ 5060Gets the value of window-local variable {varname} in {winnr} 5061(|window-number| or |window-ID|) in |tabpage-number| {tabnr}. 5062 5063{varname} is a string: 5064- Name of the variable (without "w:"). 5065- If empty, gets a dictionary with all window-local variables. 5066- If "&", gets the values of all window-local options in 5067a |Dictionary|. 5068- If it starts with "&", gets the value of a window-local 5069option. 5070 5071To get window-local variables in the current tabpage use 5072|getwinvar()|. 5073 5074When {winnr} is zero the current window is used. 5075 5076Also works for a global option, buffer-local option, 5077window-local option, and tab-local option ('cmdheight'). 5078But not for a global variable or buffer-local variable. 5079 5080When the tab, window or variable doesn't exist, {def} or an 5081empty string is returned; there is no error. 5082 5083Examples: >vim 5084let list_is_on = gettabwinvar(1, 2, '&list') 5085echo "myvar = " .. gettabwinvar(3, 1, 'myvar') 5086< 5087To get all window-local variables: >vim 5088gettabwinvar({tabnr}, {winnr}, '&') 5089< 5090]=] , 5091name ='gettabwinvar' , 5092params ={ 5093{ 'tabnr' , 'integer' } , 5094{ 'winnr' , 'integer' } , 5095{ 'varname' , 'string' } , 5096{ 'def' , 'any' } , 5097} , 5098signature ='gettabwinvar({tabnr}, {winnr}, {varname} [, {def}])' , 5099see_lua ={ 5100'|nvim_win_get_var()| or |vim.w| after resolving {tabnr} and {winnr} to a winid; option names use |nvim_get_option_value()| or |vim.wo|' , 5101} , 5102} , 5103gettagstack ={ 5104args ={ 0 , 1 } , 5105base =1 , 5106desc =[=[ 5107Returns the tag stack of window {winnr} (|window-number| or 5108|window-ID|) as a Dict. 5109When {winnr} is not specified, the current window is used. 5110When window {winnr} doesn't exist, an empty Dict is returned. 5111 5112The returned dictionary contains the following entries: 5113curidx Current index in the stack. When at 5114top of the stack, set to (length + 1). 5115Index of bottom of the stack is 1. 5116items List of items in the stack. Each item 5117is a dictionary containing the 5118entries described below. 5119length Number of entries in the stack. 5120 5121Each item in the stack is a dictionary with the following 5122entries: 5123bufnr buffer number of the current jump 5124from cursor position before the tag jump. 5125See |getpos()| for the format of the 5126returned list. 5127matchnr current matching tag number. Used 5128when multiple matching tags are found 5129for a name. 5130tagname name of the tag 5131 5132See |tagstack| for more information about the tag stack. 5133 5134]=] , 5135name ='gettagstack' , 5136params ={ { 'winnr' , 'integer' } } , 5137signature ='gettagstack([{winnr}])' , 5138} , 5139gettext ={ 5140args =1 , 5141base =1 , 5142desc =[=[ 5143Translate String {text} if possible. 5144This is mainly for use in the distributed Vim scripts. When 5145generating message translations the {text} is extracted by 5146xgettext, the translator can add the translated message in the 5147.po file and Vim will lookup the translation when gettext() is 5148called. 5149For {text} double quoted strings are preferred, because 5150xgettext does not understand escaping in single quoted 5151strings. 5152]=] , 5153name ='gettext' , 5154params ={ { 'text' , 'string' } } , 5155returns ='string' , 5156signature ='gettext({text})' , 5157} , 5158getwininfo ={ 5159args ={ 0 , 1 } , 5160base =1 , 5161desc =[=[ 5162Returns information about windows as a |List| with Dictionaries. 5163 5164If {winid} is given Information about the window with that ID 5165is returned, as a |List| with one item. If the window does not 5166exist the result is an empty list. 5167 5168Without {winid} information about all the windows in all the 5169tabpages is returned. 5170 5171Each List item is a |Dictionary| with the following entries: 5172botline last complete displayed buffer line 5173bufnr number of buffer in the window 5174height window height (excluding winbar) 5175leftcol first column displayed; only used when 5176'wrap' is off 5177loclist 1 if showing a location list 5178quickfix 1 if quickfix or location list window 5179status_height status lines height (0 or 1) 5180tabnr |tabpage-number| 5181terminal 1 if a terminal window 5182textoff number of columns occupied by any 5183'foldcolumn', 'signcolumn' and line 5184number in front of the text 5185topline first displayed buffer line 5186variables a reference to the dictionary with 5187window-local variables 5188width window width 5189winbar 1 if the window has a toolbar, 0 5190otherwise 5191wincol leftmost screen column of the window; 5192"col" from |win_screenpos()| 5193winid |window-ID| 5194winnr |window-number| 5195winrow topmost screen line of the window; 5196"row" from |win_screenpos()| 5197 5198]=] , 5199name ='getwininfo' , 5200params ={ { 'winid' , 'integer' } } , 5201signature ='getwininfo([{winid}])' , 5202returns ='vim.fn.getwininfo.ret.item[]' , 5203} , 5204getwinpos ={ 5205args ={ 0 , 1 } , 5206base =1 , 5207desc =[=[ 5208Returns the [x, y] screen position of the Nvim GUI window as 5209a |List| with two numbers (result of |getwinposx()| and 5210|getwinposy()| combined). 5211 5212{timeout} can be used to specify how long to wait in msec for 5213a response. When omitted 100 msec is used. 5214 5215Use a longer time for a remote terminal. 5216When using a value less than 10 and no response is received 5217within that time, a previously reported position is returned, 5218if available. This can be used to poll for the position and 5219do some work in the meantime: >vim 5220while 1 5221let res = getwinpos(1) 5222if res[0] >= 0 5223break 5224endif 5225" Do some work here 5226endwhile 5227< 5228]=] , 5229name ='getwinpos' , 5230params ={ { 'timeout' , 'integer' } } , 5231signature ='getwinpos([{timeout}])' , 5232} , 5233getwinposx ={ 5234desc =[=[ 5235Returns the X coordinate in pixels of the left hand side of 5236the Nvim GUI window, or -1 if not available. The value can be 5237used with `:winpos`. 5238]=] , 5239name ='getwinposx' , 5240params ={} , 5241returns ='integer' , 5242signature ='getwinposx()' , 5243} , 5244getwinposy ={ 5245desc =[=[ 5246Returns the Y coordinate in pixels of the top of the Nvim GUI 5247window, or -1 if not available. The value can be used with 5248`:winpos`. 5249]=] , 5250name ='getwinposy' , 5251params ={} , 5252returns ='integer' , 5253signature ='getwinposy()' , 5254} , 5255getwinvar ={ 5256args ={ 2 , 3 } , 5257base =1 , 5258desc =[=[ 5259Like |gettabwinvar()| for the current tabpage. 5260Examples: >vim 5261let list_is_on = getwinvar(2, '&list') 5262echo "myvar = " .. getwinvar(1, 'myvar') 5263< 5264]=] , 5265name ='getwinvar' , 5266params ={ { 'winnr' , 'integer' } , { 'varname' , 'string' } , { 'def' , 'any' } } , 5267signature ='getwinvar({winnr}, {varname} [, {def}])' , 5268see_lua ={ 5269'|nvim_win_get_var()| or |vim.w| after resolving {winnr}; option names use |nvim_get_option_value()| or |vim.wo|' , 5270} , 5271} , 5272glob ={ 5273args ={ 1 , 4 } , 5274base =1 , 5275desc =[=[ 5276Expand the file wildcards in {expr}. See |wildcards| for the 5277use of special characters. 5278 5279Unless the optional {nosuf} argument is given and is |TRUE|, 5280the 'suffixes' and 'wildignore' options apply: Names matching 5281one of the patterns in 'wildignore' will be skipped and 5282'suffixes' affect the ordering of matches. 5283'wildignorecase' always applies. 5284 5285When {list} is present and it is |TRUE| the result is a |List| 5286with all matching files. The advantage of using a List is, 5287you also get filenames containing newlines correctly. 5288Otherwise the result is a String and when there are several 5289matches, they are separated by <NL> characters. 5290 5291If the expansion fails, the result is an empty String or List. 5292 5293You can also use |readdir()| if you need to do complicated 5294things, such as limiting the number of matches. 5295 5296A name for a non-existing file is not included. A symbolic 5297link is only included if it points to an existing file. 5298However, when the {alllinks} argument is present and it is 5299|TRUE| then all symbolic links are included. 5300 5301For most systems backticks can be used to get files names from 5302any external command. Example: >vim 5303let tagfiles = glob("`find . -name tags -print`") 5304let &tags = substitute(tagfiles, "\n", ",", "g") 5305<The result of the program inside the backticks should be one 5306item per line. Spaces inside an item are allowed. 5307 5308See |expand()| for expanding special Vim variables. See 5309|system()| for getting the raw output of an external command. 5310 5311]=] , 5312name ='glob' , 5313params ={ 5314{ 'expr' , 'string' } , 5315{ 'nosuf' , 'boolean' } , 5316{ 'list' , 'boolean' } , 5317{ 'alllinks' , 'boolean' } , 5318} , 5319signature ='glob({expr} [, {nosuf} [, {list} [, {alllinks}]]])' , 5320} , 5321glob2regpat ={ 5322args =1 , 5323base =1 , 5324desc =[=[ 5325Convert a file pattern, as used by |glob()|, into a search 5326pattern. The result can be used to match with a string that 5327is a file name. E.g. >vim 5328if filename =~ glob2regpat('Make*.mak') 5329" ... 5330endif 5331<This is equivalent to: >vim 5332if filename =~ '^Make.*\.mak$' 5333" ... 5334endif 5335<When {string} is an empty string the result is "^$", match an 5336empty string. 5337Note that the result depends on the system. On MS-Windows 5338a backslash usually means a path separator. 5339 5340]=] , 5341name ='glob2regpat' , 5342params ={ { 'string' , 'string' } } , 5343returns ='string' , 5344signature ='glob2regpat({string})' , 5345} , 5346globpath ={ 5347args ={ 2 , 5 } , 5348base =2 , 5349desc =[=[ 5350Perform |glob()| for String {expr} on all directories in {path} 5351and concatenate the results. Example: >vim 5352echo globpath(&rtp, "syntax/c.vim") 5353< 5354{path} is a comma-separated list of directory names. Each 5355directory name is prepended to {expr} and expanded like with 5356|glob()|. A path separator is inserted when needed. 5357To add a comma inside a directory name escape it with a 5358backslash. Note that on MS-Windows a directory may have a 5359trailing backslash, remove it if you put a comma after it. 5360If the expansion fails for one of the directories, there is no 5361error message. 5362 5363Unless the optional {nosuf} argument is given and is |TRUE|, 5364the 'suffixes' and 'wildignore' options apply: Names matching 5365one of the patterns in 'wildignore' will be skipped and 5366'suffixes' affect the ordering of matches. 5367 5368When {list} is present and it is |TRUE| the result is a |List| 5369with all matching files. The advantage of using a List is, 5370you also get filenames containing newlines correctly. 5371Otherwise the result is a String and when there are several 5372matches, they are separated by <NL> characters. Example: >vim 5373echo globpath(&rtp, "syntax/c.vim", 0, 1) 5374< 5375{allinks} is used as with |glob()|. 5376 5377The "**" item can be used to search in a directory tree. 5378For example, to find all "README.txt" files in the directories 5379in 'runtimepath' and below: >vim 5380echo globpath(&rtp, "**/README.txt") 5381<Upwards search and limiting the depth of "**" is not 5382supported, thus using 'path' will not always work properly. 5383 5384]=] , 5385name ='globpath' , 5386params ={ 5387{ 'path' , 'string' } , 5388{ 'expr' , 'string' } , 5389{ 'nosuf' , 'boolean' } , 5390{ 'list' , 'boolean' } , 5391{ 'allinks' , 'boolean' } , 5392} , 5393signature ='globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]])' , 5394} , 5395has ={ 5396args =1 , 5397desc =[=[ 5398Returns 1 if {feature} is supported, 0 otherwise. The 5399{feature} argument is a feature name like "nvim-0.2.1" or 5400"win32", see below. See also |exists()|. 5401 5402To get the system name use |vim.uv|.os_uname() in Lua: >lua 5403print(vim.uv.os_uname().sysname) 5404 5405<If the code has a syntax error then Vimscript may skip the 5406rest of the line. Put |:if| and |:endif| on separate lines to 5407avoid the syntax error: >vim 5408if has('feature') 5409let x = this_breaks_without_the_feature() 5410endif 5411< 5412Vim's compile-time feature-names (prefixed with "+") are not 5413recognized because Nvim is always compiled with all possible 5414features. |feature-compile| 5415 5416Feature names can be: 54171. Nvim version. For example the "nvim-0.2.1" feature means 5418that Nvim is version 0.2.1 or later: >vim 5419if has("nvim-0.2.1") 5420" ... 5421endif 5422 5423<2. Runtime condition or other pseudo-feature. For example the 5424"win32" feature checks if the current system is Windows: >vim 5425if has("win32") 5426" ... 5427endif 5428< *feature-list* 5429List of supported pseudo-feature names: 5430acl |ACL| support. 5431*android* Android system (not necessarily |termux|). 5432bsd BSD system (not macOS, use "mac" for that). 5433clipboard |clipboard| provider is available. 5434fname_case Case in file names matters (for Darwin and MS-Windows 5435this is not present). 5436gui_running Nvim has a GUI. 5437hurd GNU/Hurd system. 5438iconv Can use |iconv()| for conversion. 5439linux Linux system. 5440mac MacOS system. 5441nvim This is Nvim. 5442python3 Legacy Vim |python3| interface. |has-python| 5443pythonx Legacy Vim |python_x| interface. |has-pythonx| 5444sun SunOS system. 5445*termux* Termux, an |android| terminal app and packaging environment. 5446ttyin input is a terminal (tty). 5447ttyout output is a terminal (tty). 5448unix Unix system. 5449*vim_starting* True during |startup|. 5450win32 Windows system (32 or 64 bit). 5451win64 Windows system (64 bit). 5452wsl WSL (Windows Subsystem for Linux) system. 5453 5454*has-patch* 54553. Vim patch. For example the "patch123" feature means that 5456Vim patch 123 at the current |v:version| was included: >vim 5457if v:version > 602 || v:version == 602 && has("patch148") 5458" ... 5459endif 5460 5461<4. Vim version. For example the "patch-7.4.237" feature means 5462that Nvim is Vim-compatible to version 7.4.237 or later. >vim 5463if has("patch-7.4.237") 5464" ... 5465endif 5466< 5467]=] , 5468fast =true , 5469name ='has' , 5470params ={ { 'feature' , 'string' } } , 5471returns ='0|1' , 5472signature ='has({feature})' , 5473} , 5474has_key ={ 5475args =2 , 5476base =1 , 5477desc =[=[ 5478Checks whether |Dictionary| {dict} has an entry with key 5479{key}. Returns TRUE if so, FALSE otherwise. The {key} 5480argument is a string. 5481 5482]=] , 5483name ='has_key' , 5484params ={ { 'dict' , 'table' } , { 'key' , 'string' } } , 5485returns ='0|1' , 5486signature ='has_key({dict}, {key})' , 5487see_lua ={ '`dict[key] ~= nil`' } , 5488} , 5489haslocaldir ={ 5490args ={ 0 , 3 } , 5491base =1 , 5492desc =[=[ 5493Checks whether the tabpage, window or buffer has set a local 5494working directory. Returns 1 when the window has set a local 5495path via |:lcd|, or when {winnr} is -1 and the tabpage has set 5496a local path via |:tcd|, or when {winnr} and {tabnr} are -1 5497and {bufnr} has set a local path via |:bcd|, otherwise 0. 5498 5499Tabs, windows and buffers are identified by their respective 5500numbers, 0 means current tab/window/buffer. Missing {winnr} 5501or {tabnr} implies 0 (missing {bufnr} does not; see below). 5502Thus the following are equivalent: >vim 5503echo haslocaldir() 5504echo haslocaldir(0) 5505echo haslocaldir(0, 0) 5506<With {winnr} use that window in the current tabpage. 5507With {winnr} and {tabnr} use the window in that tabpage. 5508{winnr} is a |window-number| or |window-ID|. 5509If {winnr} is -1 it is ignored, only the tab is resolved. 5510If {bufnr} is provided, {winnr} and {tabnr} must be -1 and 5511only the buffer is resolved. An argument may be -1 only if 5512all preceding arguments are -1. 5513Examples of buffer usage: >vim 5514haslocaldir(-1, -1, 0) " Current buf has a local directory? 5515haslocaldir(-1, -1, 3) " Buf #3 has a local directory? 5516<Throw error if the arguments are invalid. 5517|E5000| |E5001| |E5002| |E5006| |E5007| 5518 5519]=] , 5520name ='haslocaldir' , 5521params ={ { 'winnr' , 'integer' } , { 'tabnr' , 'integer' } , { 'bufnr' , 'integer' } } , 5522returns ='0|1' , 5523signature ='haslocaldir([{winnr} [, {tabnr} [, {bufnr} ]]])' , 5524} , 5525hasmapto ={ 5526args ={ 1 , 3 } , 5527base =1 , 5528desc =[=[ 5529Checks whether a mapping exists whose rhs contains {what}. 5530Returns TRUE if there is such a mapping in one of the modes 5531indicated by {mode}. 5532The arguments {what} and {mode} are strings. 5533When {abbr} is there and it is |TRUE| use abbreviations 5534instead of mappings. Don't forget to specify Insert and/or 5535Command-line mode. 5536Both the global mappings and the mappings local to the current 5537buffer are checked for a match. 5538If no matching mapping is found FALSE is returned. 5539The following characters are recognized in {mode}: 5540n Normal mode 5541v Visual and Select mode 5542x Visual mode 5543s Select mode 5544o Operator-pending mode 5545i Insert mode 5546l Language-Argument ("r", "f", "t", etc.) 5547c Command-line mode 5548When {mode} is omitted, "nvo" is used. 5549 5550This function is useful to check if a mapping already exists 5551to a function in a Vim script. Example: >vim 5552if !hasmapto('\ABCdoit') 5553map <Leader>d \ABCdoit 5554endif 5555<This installs the mapping to "\ABCdoit" only if there isn't 5556already a mapping to "\ABCdoit". 5557 5558]=] , 5559name ='hasmapto' , 5560params ={ { 'what' , 'any' } , { 'mode' , 'string' } , { 'abbr' , 'boolean' } } , 5561returns ='0|1' , 5562signature ='hasmapto({what} [, {mode} [, {abbr}]])' , 5563} , 5564highlightID ={ 5565args =1 , 5566base =1 , 5567deprecated =true , 5568desc =[=[ 5569Obsolete name for |hlID()|. 5570]=] , 5571func ='f_hlID' , 5572params ={ { 'name' , 'string' } } , 5573signature ='highlightID({name})' , 5574see_lua ={ '|nvim_get_hl()|' } , 5575} , 5576highlight_exists ={ 5577args =1 , 5578base =1 , 5579deprecated =true , 5580desc =[=[ 5581Obsolete name for |hlexists()|. 5582]=] , 5583func ='f_hlexists' , 5584params ={ { 'name' , 'string|number|boolean|nil' } } , 5585signature ='highlight_exists({name})' , 5586see_lua ={ '|nvim_get_hl()|' } , 5587} , 5588histadd ={ 5589args =2 , 5590base =2 , 5591desc =[=[ 5592Add the String {item} to the history {history} which can be 5593one of: *hist-names* 5594"cmd" or ":" command line history 5595"search" or "/" search pattern history 5596"expr" or "=" typed expression history 5597"input" or "@" input line history 5598"debug" or ">" debug command history 5599empty the current or last used history 5600The {history} string does not need to be the whole name, one 5601character is sufficient. 5602If {item} does already exist in the history, it will be 5603shifted to become the newest entry. 5604The result is a Number: TRUE if the operation was successful, 5605otherwise FALSE is returned. 5606 5607Example: >vim 5608call histadd("input", strftime("%Y %b %d")) 5609let date=input("Enter date: ") 5610<This function is not available in the |sandbox|. 5611 5612]=] , 5613name ='histadd' , 5614params ={ { 'history' , 'string' } , { 'item' , 'any' } } , 5615returns ='0|1' , 5616signature ='histadd({history}, {item})' , 5617} , 5618histdel ={ 5619args ={ 1 , 2 } , 5620base =1 , 5621desc =[=[ 5622Clear {history}, i.e. delete all its entries. See |hist-names| 5623for the possible values of {history}. 5624 5625If the parameter {item} evaluates to a String, it is used as a 5626regular expression. All entries matching that expression will 5627be removed from the history (if there are any). 5628Upper/lowercase must match, unless "\c" is used |/\c|. 5629If {item} evaluates to a Number, it will be interpreted as 5630an index, see |:history-indexing|. The respective entry will 5631be removed if it exists. 5632 5633The result is TRUE for a successful operation, otherwise FALSE 5634is returned. 5635 5636Examples: 5637Clear expression register history: >vim 5638call histdel("expr") 5639< 5640Remove all entries starting with "*" from the search history: >vim 5641call histdel("/", '^\*') 5642< 5643The following three are equivalent: >vim 5644call histdel("search", histnr("search")) 5645call histdel("search", -1) 5646call histdel("search", '^' .. histget("search", -1) .. '$') 5647< 5648To delete the last search pattern and use the last-but-one for 5649the "n" command and 'hlsearch': >vim 5650call histdel("search", -1) 5651let @/ = histget("search", -1) 5652< 5653]=] , 5654name ='histdel' , 5655params ={ { 'history' , 'string' } , { 'item' , 'any' } } , 5656returns ='0|1' , 5657signature ='histdel({history} [, {item}])' , 5658} , 5659histget ={ 5660args ={ 1 , 2 } , 5661base =1 , 5662desc =[=[ 5663Returns an entry from the specified command-line {history}. 5664See |hist-names| for the possible values of {history}, and 5665|:history-indexing| for {index}. If there is 5666no such entry, an empty String is returned. When {index} is 5667omitted, the most recent item from the history is used. 5668 5669Examples: 5670Redo the second last search from history. >vim 5671execute '/' .. histget("search", -2) 5672 5673<Define an Ex command ":H {num}" that supports re-execution of 5674the {num}th entry from the output of |:history|. >vim 5675command -nargs=1 H execute histget("cmd", 0+<args>) 5676< 5677]=] , 5678name ='histget' , 5679params ={ { 'history' , 'string' } , { 'index' , 'integer|string' } } , 5680returns ='string' , 5681signature ='histget({history} [, {index}])' , 5682} , 5683histnr ={ 5684args =1 , 5685base =1 , 5686desc =[=[ 5687The result is the Number of the current entry in {history}. 5688See |hist-names| for the possible values of {history}. 5689If an error occurred, -1 is returned. 5690 5691Example: >vim 5692let inp_index = histnr("expr") 5693< 5694 5695]=] , 5696name ='histnr' , 5697params ={ { 'history' , 'string' } } , 5698returns ='integer' , 5699signature ='histnr({history})' , 5700} , 5701hlID ={ 5702args =1 , 5703base =1 , 5704desc =[=[ 5705Returns the numeric ID of the highlight group with name 5706{name}. When the highlight group doesn't exist, zero is 5707returned. 5708This can be used to retrieve information about the highlight 5709group. For example, to get the background color of the 5710"Comment" group: >vim 5711echo synIDattr(synIDtrans(hlID("Comment")), "bg") 5712< 5713]=] , 5714name ='hlID' , 5715params ={ { 'name' , 'string' } } , 5716returns ='integer' , 5717signature ='hlID({name})' , 5718see_lua ={ '|nvim_get_hl()|' } , 5719} , 5720hlexists ={ 5721args =1 , 5722base =1 , 5723desc =[=[ 5724Checks whether a highlight group called {name} exists. 5725Returns TRUE if the group has been defined in some way. Not 5726necessarily when highlighting has been defined for it, it may 5727also have been used for a syntax item. 5728 5729]=] , 5730name ='hlexists' , 5731params ={ { 'name' , 'string|number|boolean|nil' } } , 5732returns ='0|1' , 5733signature ='hlexists({name})' , 5734see_lua ={ '|nvim_get_hl()|' } , 5735} , 5736hostname ={ 5737desc =[=[ 5738Returns the hostname of the machine on which the Nvim server 5739(not the UI client) is currently running. 5740]=] , 5741fast =true , 5742func_lua ='f_hostname' , 5743name ='hostname' , 5744params ={} , 5745returns ='string' , 5746signature ='hostname()' , 5747see_lua ={ '|uv.os_gethostname()|' } , 5748} , 5749iconv ={ 5750args =3 , 5751base =1 , 5752desc =[=[ 5753Converts the encoding of {string} from {from} to {to}. 5754Returns the converted String. 5755When the conversion completely fails an empty string is 5756returned. When some characters could not be converted they 5757are replaced with "?". 5758The encoding names are whatever the iconv() library function 5759can accept, see ":!man 3 iconv". 5760Note that Vim uses UTF-8 for all Unicode encodings, conversion 5761from/to UCS-2 is automatically changed to use UTF-8. You 5762cannot use UCS-2 in a string anyway, because of the NUL bytes. 5763 5764]=] , 5765fast =true , 5766name ='iconv' , 5767params ={ { 'string' , 'string' } , { 'from' , 'string' } , { 'to' , 'string' } } , 5768returns ='string' , 5769signature ='iconv({string}, {from}, {to})' , 5770see_lua ={ '|vim.iconv()|' } , 5771} , 5772id ={ 5773args =1 , 5774desc =[=[ 5775Returns a |String| which is a unique identifier of the 5776container type (|List|, |Dict|, |Blob| and |Partial|). It is 5777guaranteed that for the mentioned types `id(v1) ==# id(v2)` 5778returns true iff `type(v1) == type(v2) && v1 is v2`. 5779Note that `v:_null_string`, `v:_null_list`, `v:_null_dict` and 5780`v:_null_blob` have the same `id()` with different types 5781because they are internally represented as NULL pointers. 5782`id()` returns a hexadecimal representation of the pointers to 5783the containers (i.e. like `0x994a40`), same as `printf("%p", 5784{expr})`, but it is advised against counting on the exact 5785format of the return value. 5786 5787It is not guaranteed that `id(no_longer_existing_container)` 5788will not be equal to some other `id()`: new containers may 5789reuse identifiers of the garbage-collected ones. 5790]=] , 5791name ='id' , 5792params ={ { 'expr' , 'any' } } , 5793returns ='string' , 5794signature ='id({expr})' , 5795see_lua =false , 5796} , 5797indent ={ 5798args =1 , 5799base =1 , 5800desc =[=[ 5801Returns the indent of line {lnum} in the current buffer. 5802The indent is counted in spaces, the value of 'tabstop' is 5803relevant. {lnum} is used just like in 5804|getline()|. 5805When {lnum} is invalid -1 is returned. 5806 5807To get or set indent of lines in a string, see |vim.text.indent()|. 5808 5809]=] , 5810name ='indent' , 5811params ={ { 'lnum' , 'integer|string' } } , 5812returns ='integer' , 5813signature ='indent({lnum})' , 5814} , 5815index ={ 5816args ={ 2 , 4 } , 5817base =1 , 5818desc =[=[ 5819Find {expr} in {object} and return its index. See 5820|indexof()| for using a lambda to select the item. 5821 5822If {object} is a |List| return the lowest index where the item 5823has a value equal to {expr}. There is no automatic 5824conversion, so the String "4" is different from the Number 4. 5825And the Number 4 is different from the Float 4.0. The value 5826of 'ignorecase' is not used here, case matters as indicated by 5827the {ic} argument. 5828 5829If {object} is a |Blob| return the lowest index where the byte 5830value is equal to {expr}. 5831 5832If {start} is given then start looking at the item with index 5833{start} (may be negative for an item relative to the end). 5834 5835When {ic} is given and it is |TRUE|, ignore case. Otherwise 5836case must match. 5837 5838-1 is returned when {expr} is not found in {object}. 5839Example: >vim 5840let idx = index(words, "the") 5841if index(numbers, 123) >= 0 5842" ... 5843endif 5844< 5845 5846]=] , 5847name ='index' , 5848params ={ { 'object' , 'any' } , { 'expr' , 'any' } , { 'start' , 'integer' } , { 'ic' , 'boolean' } } , 5849returns ='integer' , 5850signature ='index({object}, {expr} [, {start} [, {ic}]])' , 5851see_lua ={ 5852'|vim.iter()| with |Iter:enumerate()| and |Iter:find()| for lists; result is 1-based, and `start`, `ic`, and Blob semantics differ' , 5853} , 5854} , 5855indexof ={ 5856args ={ 2 , 3 } , 5857base =1 , 5858desc =[=[ 5859Returns the index of an item in {object} where {expr} is 5860v:true. {object} must be a |List| or a |Blob|. 5861 5862If {object} is a |List|, evaluate {expr} for each item in the 5863List until the expression is v:true and return the index of 5864this item. 5865 5866If {object} is a |Blob| evaluate {expr} for each byte in the 5867Blob until the expression is v:true and return the index of 5868this byte. 5869 5870{expr} must be a |string| or |Funcref|. 5871 5872If {expr} is a |string|: If {object} is a |List|, inside 5873{expr} |v:key| has the index of the current List item and 5874|v:val| has the value of the item. If {object} is a |Blob|, 5875inside {expr} |v:key| has the index of the current byte and 5876|v:val| has the byte value. 5877 5878If {expr} is a |Funcref| it must take two arguments: 58791. the key or the index of the current item. 58802. the value of the current item. 5881The function must return |TRUE| if the item is found and the 5882search should stop. 5883 5884The optional argument {opts} is a Dict and supports the 5885following items: 5886startidx start evaluating {expr} at the item with this 5887index; may be negative for an item relative to 5888the end 5889Returns -1 when {expr} evaluates to v:false for all the items. 5890Example: >vim 5891let l = [#{n: 10}, #{n: 20}, #{n: 30}] 5892echo indexof(l, "v:val.n == 20") 5893echo indexof(l, {i, v -> v.n == 30}) 5894echo indexof(l, "v:val.n == 20", #{startidx: 1}) 5895< 5896 5897]=] , 5898name ='indexof' , 5899params ={ { 'object' , 'any' } , { 'expr' , 'any' } , { 'opts' , 'table' } } , 5900returns ='integer' , 5901signature ='indexof({object}, {expr} [, {opts}])' , 5902see_lua ={ 5903'|vim.iter()| with |Iter:enumerate()| and |Iter:find()| for list predicates; result is 1-based, and `startidx` and Blob semantics differ' , 5904} , 5905} , 5906input ={ 5907args ={ 1 , 3 } , 5908base =1 , 5909desc ='' , 5910name ='input' , 5911params ={ { 'prompt' , 'string' } , { 'text' , 'string' } , { 'completion' , 'string' } } , 5912returns ='string' , 5913signature ='input({prompt} [, {text} [, {completion}]])' , 5914see_lua ={ '|vim.ui.input()| for callback-based input' } , 5915} , 5916input__1 ={ 5917args ={ 1 , 3 } , 5918base =1 , 5919desc =[=[ 5920Prompts the user to enter text on the command-line, and 5921returns the text as a String. The {prompt} argument is either 5922a prompt string, or a blank string (for no prompt). A '\n' 5923can be used in the prompt to start a new line. 5924 5925In the second form it accepts a single dictionary with the 5926following keys, any of which may be omitted: 5927 5928Key Default Description ~ 5929prompt "" Same as {prompt} in the first form. 5930default "" Same as {text} in the first form. 5931completion nothing Same as {completion} in the first form. 5932cancelreturn "" The value returned when the dialog is 5933cancelled. 5934highlight nothing Highlight handler: |Funcref|. 5935 5936The highlighting set with |:echohl| is used for the prompt. 5937The input is entered just like a command-line, with the same 5938editing commands and mappings. There is a separate history 5939for lines typed for input(). 5940Example: >vim 5941if input("Coffee or beer? ") == "beer" 5942echo "Cheers!" 5943endif 5944< 5945If the optional {text} argument is present and not empty, this 5946is used for the default reply, as if the user typed this. 5947Example: >vim 5948let color = input("Color? ", "white") 5949 5950<The optional {completion} argument specifies the type of 5951completion supported for the input. Without it completion is 5952not performed. The supported completion types are the same as 5953that can be supplied to a user-defined command using the 5954"-complete=" argument. Refer to |:command-completion| for 5955more information. Example: >vim 5956let fname = input("File: ", "", "file") 5957 5958< *input()-highlight* *E5400* *E5402* 5959The optional `highlight` key allows specifying function which 5960will be used for highlighting user input. This function 5961receives user input as its only argument and must return 5962a list of 3-tuples [hl_start_col, hl_end_col + 1, hl_group] 5963where 5964hl_start_col is the first highlighted column, 5965hl_end_col is the last highlighted column (+ 1!), 5966hl_group is |:hi| group used for highlighting. 5967*E5403* *E5404* *E5405* *E5406* 5968Both hl_start_col and hl_end_col + 1 must point to the start 5969of the multibyte character (highlighting must not break 5970multibyte characters), hl_end_col + 1 may be equal to the 5971input length. Start column must be in range [0, len(input)), 5972end column must be in range (hl_start_col, len(input)], 5973sections must be ordered so that next hl_start_col is greater 5974then or equal to previous hl_end_col. 5975 5976Example (try some input with parentheses): >vim 5977highlight RBP1 guibg=Red ctermbg=red 5978highlight RBP2 guibg=Yellow ctermbg=yellow 5979highlight RBP3 guibg=Green ctermbg=green 5980highlight RBP4 guibg=Blue ctermbg=blue 5981let g:rainbow_levels = 4 5982function! RainbowParens(cmdline) 5983let ret = [] 5984let i = 0 5985let lvl = 0 5986while i < len(a:cmdline) 5987if a:cmdline[i] is# '(' 5988call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)]) 5989let lvl += 1 5990elseif a:cmdline[i] is# ')' 5991let lvl -= 1 5992call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)]) 5993endif 5994let i += 1 5995endwhile 5996return ret 5997endfunction 5998call input({'prompt':'>','highlight':'RainbowParens'}) 5999< 6000Highlight function is called at least once for each new 6001displayed input string, before command-line is redrawn. It is 6002expected that function is pure for the duration of one input() 6003call, i.e. it produces the same output for the same input, so 6004output may be memoized. Function is run like under |:silent| 6005modifier. If the function causes any errors, it will be 6006skipped for the duration of the current input() call. 6007 6008Highlighting is disabled if command-line contains arabic 6009characters. 6010 6011NOTE: This function must not be used in a startup file, for 6012the versions that only run in GUI mode (e.g., the Win32 GUI). 6013Note: When input() is called from within a mapping it will 6014consume remaining characters from that mapping, because a 6015mapping is handled like the characters were typed. 6016Use |inputsave()| before input() and |inputrestore()| 6017after input() to avoid that. Another solution is to avoid 6018that further characters follow in the mapping, e.g., by using 6019|:execute| or |:normal|. 6020 6021Example with a mapping: >vim 6022nmap \x :call GetFoo()<CR>:exe "/" .. Foo<CR> 6023function GetFoo() 6024call inputsave() 6025let g:Foo = input("enter search pattern: ") 6026call inputrestore() 6027endfunction 6028< 6029 6030]=] , 6031name ='input' , 6032params ={ { 'opts' , 'table' } } , 6033returns ='string' , 6034signature ='input({opts})' , 6035see_lua ={ '|vim.ui.input()| for callback-based input' } , 6036} , 6037inputdialog ={ 6038args ={ 1 , 3 } , 6039base =1 , 6040deprecated =true , 6041desc =[=[ 6042Use |input()| instead. 6043]=] , 6044params =VARARGS , 6045signature ='input(...)' , 6046see_lua ={ '|vim.ui.input()| for callback-based input' } , 6047} , 6048inputlist ={ 6049args =1 , 6050base =1 , 6051desc =[=[ 6052Displays a list of strings and prompts the user to select 6053one by entering a number. {textlist} must be a |List| of 6054strings. Returns the number the user entered. 6055The user can also select an item by clicking on it with the 6056mouse, if the mouse is enabled in the command line ('mouse' is 6057"a" or includes "c"). For the first string 0 is returned. 6058When clicking above the first item a negative number is 6059returned. When clicking on the prompt one more than the 6060length of {textlist} is returned. 6061Make sure {textlist} has less than 'lines' entries, otherwise 6062it won't work. It's a good idea to put the entry number at 6063the start of the string. And put a prompt in the first item. 6064Example: >vim 6065let color = inputlist(['Select color:', '1. red', 6066\ '2. green', '3. blue']) 6067< 6068]=] , 6069name ='inputlist' , 6070params ={ { 'textlist' , 'string[]' } } , 6071signature ='inputlist({textlist})' , 6072see_lua ={ 6073'|vim.ui.select()| for simple selection menus; callback, returned item, and out-of-range semantics differ' , 6074} , 6075} , 6076inputrestore ={ 6077desc =[=[ 6078Restore typeahead that was saved with a previous |inputsave()|. 6079Should be called the same number of times |inputsave()| is 6080called. Calling it more often is harmless though. 6081Returns TRUE when there is nothing to restore, FALSE 6082otherwise. 6083]=] , 6084name ='inputrestore' , 6085params ={} , 6086returns ='integer' , 6087signature ='inputrestore()' , 6088} , 6089inputsave ={ 6090desc =[=[ 6091Preserve typeahead (also from mappings) and clear it, so that 6092a following prompt gets input from the user. Should be 6093followed by a matching |inputrestore()| after the prompt. Can 6094be used several times, in which case there must be just as 6095many |inputrestore()| calls. 6096Returns TRUE when out of memory, FALSE otherwise. 6097]=] , 6098name ='inputsave' , 6099params ={} , 6100returns ='integer' , 6101signature ='inputsave()' , 6102} , 6103inputsecret ={ 6104args ={ 1 , 2 } , 6105base =1 , 6106desc =[=[ 6107This function acts much like the |input()| function with but 6108two exceptions: 6109a) the user's response will be displayed as a sequence of 6110asterisks ("*") thereby keeping the entry secret, and 6111b) the user's response will not be recorded on the input 6112|history| stack. 6113The result is a String, which is whatever the user actually 6114typed on the command-line in response to the issued prompt. 6115NOTE: Command-line completion is not supported. 6116 6117]=] , 6118name ='inputsecret' , 6119params ={ { 'prompt' , 'string' } , { 'text' , 'string' } } , 6120returns ='string' , 6121signature ='inputsecret({prompt} [, {text}])' , 6122} , 6123insert ={ 6124args ={ 2 , 3 } , 6125base =1 , 6126desc =[=[ 6127When {object} is a |List| or a |Blob| insert {item} at the start 6128of it. 6129 6130If {idx} is specified insert {item} before the item with index 6131{idx}. If {idx} is zero it goes before the first item, just 6132like omitting {idx}. A negative {idx} is also possible, see 6133|list-index|. -1 inserts just before the last item. 6134 6135Returns the resulting |List| or |Blob|. Examples: >vim 6136let mylist = insert([2, 3, 5], 1) 6137call insert(mylist, 4, -1) 6138call insert(mylist, 6, len(mylist)) 6139<The last example can be done simpler with |add()|. 6140Note that when {item} is a |List| it is inserted as a single 6141item. Use |extend()| to concatenate |Lists|. 6142 6143]=] , 6144name ='insert' , 6145params ={ { 'object' , 'any' } , { 'item' , 'any' } , { 'idx' , 'integer' } } , 6146signature ='insert({object}, {item} [, {idx}])' , 6147see_lua ={ '|table.insert()| for lists; blob insertion and negative indexes differ' } , 6148} , 6149interrupt ={ 6150args =0 , 6151desc =[=[ 6152Interrupt script execution. It works more or less like the 6153user typing CTRL-C, most commands won't execute and control 6154returns to the user. This is useful to abort execution 6155from lower down, e.g. in an autocommand. Example: >vim 6156function s:check_typoname(file) 6157if fnamemodify(a:file, ':t') == '[' 6158echomsg 'Maybe typo' 6159call interrupt() 6160endif 6161endfunction 6162au BufWritePre * call s:check_typoname(expand('<amatch>')) 6163< 6164]=] , 6165name ='interrupt' , 6166params ={} , 6167signature ='interrupt()' , 6168see_lua =false , 6169} , 6170invert ={ 6171args =1 , 6172base =1 , 6173desc =[=[ 6174Bitwise invert. The argument is converted to a number. A 6175List, Dict or Float argument causes an error. Example: >vim 6176let bits = invert(bits) 6177< 6178]=] , 6179name ='invert' , 6180params ={ { 'expr' , 'integer' } } , 6181returns ='integer' , 6182signature ='invert({expr})' , 6183see_lua ={ '|bit.bnot()|' } , 6184} , 6185isabsolutepath ={ 6186args =1 , 6187base =1 , 6188desc =[=[ 6189Checks whether {path} is an absolute path. Returns |TRUE| 6190if so, |FALSE| otherwise. 6191On Unix, a path is considered absolute when it starts with 6192'/'. 6193On MS-Windows, it is considered absolute when it starts with 6194an optional drive prefix and is followed by a '\' or '/'. UNC 6195paths are always absolute. 6196Example: >vim 6197echo isabsolutepath('/usr/share/') " 1 6198echo isabsolutepath('./foobar') " 0 6199echo isabsolutepath('C:\Windows') " 1 6200echo isabsolutepath('foobar') " 0 6201echo isabsolutepath('\\remote\file') " 1 6202< 6203]=] , 6204fast =true , 6205name ='isabsolutepath' , 6206params ={ { 'path' , 'string' } } , 6207returns ='0|1' , 6208signature ='isabsolutepath({path})' , 6209} , 6210isdirectory ={ 6211args =1 , 6212base =1 , 6213desc =[=[ 6214Returns |TRUE| if {directory} exists, or |FALSE| if it doesn't 6215exist or isn't a directory. {directory} is any expression, 6216which is used as a String. 6217 6218]=] , 6219fast =true , 6220name ='isdirectory' , 6221params ={ { 'directory' , 'string' } } , 6222returns ='0|1' , 6223signature ='isdirectory({directory})' , 6224see_lua ={ '|uv.fs_stat()| and check `type == "directory"`' } , 6225} , 6226isinf ={ 6227args =1 , 6228base =1 , 6229desc =[=[ 6230Return 1 if {expr} is a positive infinity, or -1 a negative 6231infinity, otherwise 0. >vim 6232echo isinf(1.0 / 0.0) 6233< 1 >vim 6234echo isinf(-1.0 / 0.0) 6235< -1 6236 6237]=] , 6238name ='isinf' , 6239params ={ { 'expr' , 'number' } } , 6240returns ='1|0|-1' , 6241signature ='isinf({expr})' , 6242see_lua ={ '`expr == math.huge and 1 or expr == -math.huge and -1 or 0`' } , 6243} , 6244islocked ={ 6245args =1 , 6246base =1 , 6247desc =[=[ 6248Returns |TRUE| if {expr} is the name of a locked variable, 6249else |FALSE|. 6250The string argument {expr} must be the name of a variable, 6251|List| item or |Dictionary| entry, not the variable itself! 6252Example: >vim 6253let alist = [0, ['a', 'b'], 2, 3] 6254lockvar 1 alist 6255echo islocked('alist') " 1 6256echo islocked('alist[1]') " 0 6257 6258<When {expr} is a variable that does not exist you get an error 6259message. Use |exists()| to check for existence. 6260 6261]=] , 6262name ='islocked' , 6263params ={ { 'expr' , 'any' } } , 6264returns ='0|1' , 6265signature ='islocked({expr})' , 6266tags ={ 'E786' } , 6267see_lua =false , 6268} , 6269isnan ={ 6270args =1 , 6271base =1 , 6272desc =[=[ 6273Return |TRUE| if {expr} is a float with value NaN. >vim 6274echo isnan(0.0 / 0.0) 6275< 1 6276 6277]=] , 6278name ='isnan' , 6279params ={ { 'expr' , 'number' } } , 6280returns ='0|1' , 6281signature ='isnan({expr})' , 6282see_lua ={ '`expr ~= expr`' } , 6283} , 6284items ={ 6285args =1 , 6286base =1 , 6287desc =[=[ 6288Return a |List| with all key/index and value pairs of {expr}. 6289Each |List| item is a list with two items: 6290- for a |Dict|: the key and the value 6291- for a |List|, |Blob| or |String|: the index and the value 6292The returned |List| is in arbitrary order for a |Dict|, 6293otherwise it's in ascending order of the index. 6294 6295Also see |keys()| and |values()|. 6296 6297Example: >vim 6298let mydict = #{a: 'red', b: 'blue'} 6299for [key, value] in items(mydict) 6300echo $"{key} = {value}" 6301endfor 6302echo items([1, 2, 3]) 6303echo items("foobar") 6304echo items(0z0102) 6305< 6306]=] , 6307name ='items' , 6308params ={ { 'expr' , 'table|string' } } , 6309signature ='items({expr})' , 6310see_lua ={ '|pairs()|' , '|ipairs()|' } , 6311} , 6312jobclose ={ 6313args ={ 1 , 2 } , 6314deprecated =true , 6315desc =[=[ 6316Obsolete name for |chanclose()| 6317]=] , 6318func ='f_chanclose' , 6319params =VARARGS , 6320signature ='jobclose({id} [, {stream}])' , 6321} , 6322jobpid ={ 6323args =1 , 6324desc =[=[ 6325Return the PID (process id) of |job-id| {job}. 6326]=] , 6327name ='jobpid' , 6328params ={ { 'job' , 'integer' } } , 6329returns ='integer' , 6330signature ='jobpid({job})' , 6331see_lua ={ '|vim.system()| object `.pid`; |job-id| and channel semantics differ' } , 6332} , 6333jobresize ={ 6334args =3 , 6335desc =[=[ 6336Resize the pseudo terminal window of |job-id| {job} to {width} 6337columns and {height} rows. 6338Fails if the job was not started with `"pty":v:true`. 6339]=] , 6340name ='jobresize' , 6341params ={ { 'job' , 'integer' } , { 'width' , 'integer' } , { 'height' , 'integer' } } , 6342signature ='jobresize({job}, {width}, {height})' , 6343} , 6344jobsend ={ 6345args =2 , 6346deprecated =true , 6347desc =[=[ 6348Obsolete name for |chansend()| 6349]=] , 6350func ='f_chansend' , 6351params =VARARGS , 6352signature ='jobsend({id}, {data})' , 6353see_lua ={ '|nvim_chan_send()| for string data; list input and the return value differ' } , 6354} , 6355jobstart ={ 6356args ={ 1 , 2 } , 6357desc =[=[ 6358Spawns {cmd} as a job. 6359If {cmd} is a List it runs directly (no 'shell'). 6360If {cmd} is a String it runs in the 'shell', like this: >vim 6361call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}']) 6362<(See |shell-unquoting| for details.) 6363 6364Example: start a job and handle its output: >vim 6365call jobstart(['nvim', '-h'], {'on_stdout':{j,d,e->append(line('.'),d)}}) 6366< 6367Example: start a job in a |terminal| connected to the current buffer: >vim 6368call jobstart(['nvim', '-h'], {'term':v:true}) 6369< 6370Returns |job-id| on success, 0 on invalid arguments (or job 6371table is full), -1 if {cmd}[0] or 'shell' is not executable. 6372The returned job-id is a valid |channel-id| representing the 6373job's stdio streams. Use |chansend()| (or |rpcnotify()| and 6374|rpcrequest()| if "rpc" was enabled) to send data to stdin and 6375|chanclose()| to close the streams without stopping the job. 6376 6377See |job-control| and |RPC|. 6378 6379NOTE: on Windows if {cmd} is a List: 6380- cmd[0] must be an executable (not a "built-in"). If it is 6381in $PATH it can be called by name, without an extension: >vim 6382call jobstart(['ping', 'neovim.io']) 6383< If it is a full or partial path, extension is required: >vim 6384call jobstart(['System32\ping.exe', 'neovim.io']) 6385< - {cmd} is collapsed to a string of quoted args as expected 6386by CommandLineToArgvW https://msdn.microsoft.com/bb776391 6387unless cmd[0] is some form of "cmd.exe". 6388 6389*jobstart-env* 6390The job environment is initialized as follows: 6391$NVIM is set to |v:servername| of the parent Nvim 6392$NVIM_LISTEN_ADDRESS is unset 6393$NVIM_LOG_FILE is unset 6394$VIM is unset 6395$VIMRUNTIME is unset 6396You can set these with the `env` option. 6397 6398*jobstart-options* 6399{opts} is a dictionary with these keys: 6400clear_env: (boolean) `env` defines the job environment 6401exactly, instead of merging current environment. 6402cwd: (string, default=|current-directory|) Working 6403directory of the job. 6404detach: (boolean) Detach the job process: it will not be 6405killed when Nvim exits. If the process exits 6406before Nvim, `on_exit` will be invoked. 6407env: (dict) Map of environment variable name:value 6408pairs extending (or replace with "clear_env") 6409the current environment. |jobstart-env| 6410height: (number) Height of the `pty` terminal. 6411|on_exit|: (function) Callback invoked when the job exits. 6412|on_stdout|: (function) Callback invoked when the job emits 6413stdout data. 6414|on_stderr|: (function) Callback invoked when the job emits 6415stderr data. 6416overlapped: (boolean) Sets FILE_FLAG_OVERLAPPED for the 6417stdio passed to the child process. Only on 6418MS-Windows; ignored on other platforms. 6419pty: (boolean) Connect the job to a new pseudo 6420terminal, and its streams to the master file 6421descriptor. `on_stdout` receives all output, 6422`on_stderr` is ignored. Note: if the child writes 6423a query (DA1, OSC, …), it may hang or timeout waiting 6424for a response! To avoid that, `on_stdout` should 6425reply via |nvim_chan_send()| on the child's stdin. 6426See |terminal-start| |terminal-concepts| 6427rpc: (boolean) Use |msgpack-rpc| to communicate with 6428the job over stdio. Then `on_stdout` is ignored, 6429but `on_stderr` can still be used. 6430stderr_buffered: (boolean) Collect data until EOF (stream closed) 6431before invoking `on_stderr`. |channel-buffered| 6432stdout_buffered: (boolean) Collect data until EOF (stream 6433closed) before invoking `on_stdout`. |channel-buffered| 6434stdin: (string) Either "pipe" (default) to connect the 6435job's stdin to a channel or "null" to disconnect 6436stdin. 6437term: (boolean) Spawns {cmd} in a new pseudo-terminal 6438session connected to the current (unmodified) buffer. 6439Implies "pty". Defaults "height" and "width" to the 6440current window dimensions. Defaults $TERM to 6441"xterm-256color". 6442width: (number) Width of the `pty` pseudo-terminal. 6443 6444{opts} is passed as |self| dictionary to the callback; the 6445caller may set other keys to pass application-specific data. 6446 6447Returns: 6448- |channel-id| on success 6449- 0 on invalid arguments 6450- -1 if {cmd}[0] is not executable. 6451See also |job-control|, |channel|, |msgpack-rpc|. 6452]=] , 6453name ='jobstart' , 6454params ={ { 'cmd' , 'string|string[]' } , { 'opts' , 'table' } } , 6455returns ='integer' , 6456signature ='jobstart({cmd} [, {opts}])' , 6457see_lua ={ 6458'|vim.system()| for simple processes; |RPC|, PTY/term, streaming callbacks, and shell-string behavior differ' , 6459} , 6460} , 6461jobstop ={ 6462args =1 , 6463desc =[=[ 6464Stop |job-id| {id} by sending SIGTERM to the job process. If 6465the process does not terminate after a timeout then SIGKILL 6466will be sent. When the job terminates its |on_exit| handler 6467(if any) will be invoked. 6468See |job-control|. 6469 6470Returns 1 for valid job id, 0 for invalid id, including jobs have 6471exited or stopped. 6472]=] , 6473name ='jobstop' , 6474params ={ { 'id' , 'integer' } } , 6475returns ='integer' , 6476signature ='jobstop({id})' , 6477see_lua ={ '|SystemObj:kill()| on a |vim.system()| object; |job-id| semantics differ' } , 6478} , 6479jobwait ={ 6480args ={ 1 , 2 } , 6481desc =[=[ 6482Waits for jobs and their |on_exit| handlers to complete. 6483 6484{jobs} is a List of |job-id|s to wait for. 6485{timeout} is the maximum waiting time in milliseconds. If 6486omitted or -1, wait forever. 6487 6488Timeout of 0 can be used to check the status of a job: >vim 6489let running = jobwait([{job-id}], 0)[0] == -1 6490< 6491During jobwait() callbacks for jobs not in the {jobs} list may 6492be invoked. The screen will not redraw unless |:redraw| is 6493invoked by a callback. 6494 6495Returns a list of len({jobs}) integers, where each integer is 6496the status of the corresponding job: 6497Exit-code, if the job exited 6498-1 if the timeout was exceeded 6499-2 if the job was interrupted (by |CTRL-C|) 6500-3 if the job-id is invalid 6501]=] , 6502name ='jobwait' , 6503params ={ { 'jobs' , 'integer[]' } , { 'timeout' , 'integer' } } , 6504returns ='integer[]' , 6505signature ='jobwait({jobs} [, {timeout}])' , 6506see_lua ={ 6507'|SystemObj:wait()| on a |vim.system()| object; list input and status values differ' , 6508} , 6509} , 6510join ={ 6511args ={ 1 , 2 } , 6512base =1 , 6513desc =[=[ 6514Join the items in {list} together into one String. 6515When {sep} is specified it is put in between the items. If 6516{sep} is omitted a single space is used. 6517Note that {sep} is not added at the end. You might want to 6518add it there too: >vim 6519let lines = join(mylist, "\n") .. "\n" 6520<String items are used as-is. |Lists| and |Dictionaries| are 6521converted into a string like with |string()|. 6522The opposite function is |split()|. 6523 6524]=] , 6525name ='join' , 6526params ={ { 'list' , 'any[]' } , { 'sep' , 'string' } } , 6527returns ='string' , 6528signature ='join({list} [, {sep}])' , 6529see_lua ={ '|table.concat()| for string lists; non-string values stringify differently' } , 6530} , 6531json_decode ={ 6532args =1 , 6533base =1 , 6534desc =[=[ 6535Convert {expr} from JSON object. Accepts |readfile()|-style 6536list as the input, as well as regular string. May output any 6537Vim value. In the following cases it will output 6538|msgpack-special-dict|: 65391. Dictionary contains duplicate key. 65402. String contains NUL byte. Two special dictionaries: for 6541dictionary and for string will be emitted in case string 6542with NUL byte was a dictionary key. 6543 6544Note: function treats its input as UTF-8 always. The JSON 6545standard allows only a few encodings, of which UTF-8 is 6546recommended and the only one required to be supported. 6547Non-UTF-8 characters are an error. 6548 6549]=] , 6550name ='json_decode' , 6551params ={ { 'expr' , 'any' } } , 6552signature ='json_decode({expr})' , 6553see_lua ={ '|vim.json.decode()|' } , 6554} , 6555json_encode ={ 6556args =1 , 6557base =1 , 6558desc =[=[ 6559Convert {expr} into a JSON string. Accepts 6560|msgpack-special-dict| as the input. Will not convert 6561|Funcref|s, mappings with non-string keys (can be created as 6562|msgpack-special-dict|), values with self-referencing 6563containers, strings which contain non-UTF-8 characters, 6564pseudo-UTF-8 strings which contain codepoints reserved for 6565surrogate pairs (such strings are not valid UTF-8 strings). 6566Non-printable characters are converted into "\u1234" escapes 6567or special escapes like "\t", other are dumped as-is. 6568|Blob|s are converted to arrays of the individual bytes. 6569 6570]=] , 6571name ='json_encode' , 6572params ={ { 'expr' , 'any' } } , 6573returns ='string' , 6574signature ='json_encode({expr})' , 6575see_lua ={ '|vim.json.encode()|' } , 6576} , 6577keys ={ 6578args =1 , 6579base =1 , 6580desc =[=[ 6581Return a |List| with all the keys of {dict}. The |List| is in 6582arbitrary order. Also see |items()| and |values()|. 6583 6584]=] , 6585name ='keys' , 6586params ={ { 'dict' , 'table' } } , 6587returns ='string[]' , 6588signature ='keys({dict})' , 6589see_lua ={ '|vim.tbl_keys()|' } , 6590} , 6591keytrans ={ 6592args =1 , 6593base =1 , 6594desc =[=[ 6595Turn the internal byte representation of keys into a form that 6596can be used for |:map|. E.g. >vim 6597let xx = "\<C-Home>" 6598echo keytrans(xx) 6599< <C-Home> 6600 6601]=] , 6602fast =true , 6603name ='keytrans' , 6604params ={ { 'string' , 'string' } } , 6605returns ='string' , 6606signature ='keytrans({string})' , 6607} , 6608last_buffer_nr ={ 6609deprecated =true , 6610desc =[=[ 6611Obsolete name for bufnr("$"). 6612]=] , 6613params ={} , 6614signature ='last_buffer_nr()' , 6615} , 6616len ={ 6617args =1 , 6618base =1 , 6619desc =[=[ 6620Returns the length of the argument. 6621When {expr} is a String or a Number the length in bytes is 6622used, as with |strlen()|. 6623When {expr} is a |List| the number of items in the |List| is 6624returned. 6625When {expr} is a |Blob| the number of bytes is returned. 6626When {expr} is a |Dictionary| the number of entries in the 6627|Dictionary| is returned. 6628Otherwise an error is given and returns zero. 6629 6630]=] , 6631name ='len' , 6632params ={ { 'expr' , 'any[]' } } , 6633returns ='integer' , 6634signature ='len({expr})' , 6635tags ={ 'E701' } , 6636see_lua ={ 'Lua `#` operator for strings and lists' , '`#vim.tbl_keys(expr)` for dicts' } , 6637} , 6638libcall ={ 6639args =3 , 6640base =3 , 6641desc =[=[ 6642Call function {funcname} in the run-time library {libname} 6643with single argument {argument}. 6644This is useful to call functions in a library that you 6645especially made to be used with Vim. Since only one argument 6646is possible, calling standard library functions is rather 6647limited. 6648The result is the String returned by the function. If the 6649function returns NULL, this will appear as an empty string "" 6650to Vim. 6651If the function returns a number, use |libcallnr()|! 6652If {argument} is a number, it is passed to the function as an 6653int; if {argument} is a string, it is passed as a 6654null-terminated string. 6655 6656libcall() allows you to write your own 'plug-in' extensions to 6657Vim without having to recompile the program. It is NOT a 6658means to call system functions! If you try to do so Vim will 6659very probably crash. 6660 6661For Win32, the functions you write must be placed in a DLL 6662and use the normal C calling convention (NOT Pascal which is 6663used in Windows System DLLs). The function must take exactly 6664one parameter, either a character pointer or a long integer, 6665and must return a character pointer or NULL. The character 6666pointer returned must point to memory that will remain valid 6667after the function has returned (e.g. in static data in the 6668DLL). If it points to allocated memory, that memory will 6669leak away. Using a static buffer in the function should work, 6670it's then freed when the DLL is unloaded. 6671 6672WARNING: If the function returns a non-valid pointer, Vim may 6673crash! This also happens if the function returns a number, 6674because Vim thinks it's a pointer. 6675For Win32 systems, {libname} should be the filename of the DLL 6676without the ".DLL" suffix. A full path is only required if 6677the DLL is not in the usual places. 6678For Unix: When compiling your own plugins, remember that the 6679object code must be compiled as position-independent ('PIC'). 6680Examples: >vim 6681echo libcall("libc.so", "getenv", "HOME") 6682< 6683]=] , 6684name ='libcall' , 6685params ={ { 'libname' , 'string' } , { 'funcname' , 'string' } , { 'argument' , 'any' } } , 6686signature ='libcall({libname}, {funcname}, {argument})' , 6687tags ={ 'E364' , 'E368' } , 6688see_lua ={ '|package.loadlib()|' , '`ffi.load()`' } , 6689} , 6690libcallnr ={ 6691args =3 , 6692base =3 , 6693desc =[=[ 6694Just like |libcall()|, but used for a function that returns an 6695int instead of a string. 6696Examples: >vim 6697echo libcallnr("/usr/lib/libc.so", "getpid", "") 6698call libcallnr("libc.so", "printf", "Hello World!\n") 6699call libcallnr("libc.so", "sleep", 10) 6700< 6701]=] , 6702name ='libcallnr' , 6703params ={ { 'libname' , 'string' } , { 'funcname' , 'string' } , { 'argument' , 'any' } } , 6704signature ='libcallnr({libname}, {funcname}, {argument})' , 6705see_lua ={ '|package.loadlib()|' , '`ffi.load()`' } , 6706} , 6707line ={ 6708args ={ 1 , 2 } , 6709base =1 , 6710desc =[=[ 6711See |getpos()| for accepted positions. 6712 6713To get the column number use |col()|. To get both use 6714|getpos()|. 6715 6716With the optional {winid} argument the values are obtained for 6717that window instead of the current window. 6718 6719Returns 0 for invalid values of {expr} and {winid}. 6720 6721Examples: >vim 6722echo line(".") " line number of the cursor 6723echo line(".", winid) " idem, in window "winid" 6724echo line("'t") " line number of mark t 6725echo line("'" .. marker) " line number of mark marker 6726< 6727To jump to the last known position when opening a file see 6728|last-position-jump|. 6729 6730]=] , 6731name ='line' , 6732params ={ { 'expr' , 'string|integer[]' } , { 'winid' , 'integer' } } , 6733returns ='integer' , 6734signature ='line({expr} [, {winid}])' , 6735see_lua ={ 6736'|nvim_win_get_cursor()| for "." or |nvim_buf_line_count()| for "$"; marks, lists, and other position expressions differ' , 6737} , 6738} , 6739line2byte ={ 6740args =1 , 6741base =1 , 6742desc =[=[ 6743Return the byte count from the start of the buffer for line 6744{lnum}. This includes the end-of-line character, depending on 6745the 'fileformat' option for the current buffer. The first 6746line returns 1. UTF-8 encoding is used, 'fileencoding' is 6747ignored. This can also be used to get the byte count for the 6748line just below the last line: >vim 6749echo line2byte(line("$") + 1) 6750<This is the buffer size plus one. If 'fileencoding' is empty 6751it is the file size plus one. {lnum} is used like with 6752|getline()|. When {lnum} is invalid -1 is returned. 6753Also see |byte2line()|, |go| and |:goto|. 6754 6755]=] , 6756name ='line2byte' , 6757params ={ { 'lnum' , 'integer|string' } } , 6758returns ='integer' , 6759signature ='line2byte({lnum})' , 6760see_lua ={ 6761"|nvim_buf_get_offset()| with `lnum - 1`; 'fileformat' and invalid-line semantics differ" , 6762} , 6763} , 6764lispindent ={ 6765args =1 , 6766base =1 , 6767desc =[=[ 6768Get the amount of indent for line {lnum} according the lisp 6769indenting rules, as with 'lisp'. 6770The indent is counted in spaces, the value of 'tabstop' is 6771relevant. {lnum} is used just like in |getline()|. 6772When {lnum} is invalid, -1 is returned. 6773 6774]=] , 6775name ='lispindent' , 6776params ={ { 'lnum' , 'integer|string' } } , 6777returns ='integer' , 6778signature ='lispindent({lnum})' , 6779} , 6780list2blob ={ 6781args =1 , 6782base =1 , 6783desc =[=[ 6784Return a Blob concatenating all the number values in {list}. 6785Examples: >vim 6786echo list2blob([1, 2, 3, 4]) " returns 0z01020304 6787echo list2blob([]) " returns 0z 6788<Returns an empty Blob on error. If one of the numbers is 6789negative or more than 255 error *E1239* is given. 6790 6791|blob2list()| does the opposite. 6792 6793]=] , 6794name ='list2blob' , 6795params ={ { 'list' , 'any[]' } } , 6796returns ='string' , 6797signature ='list2blob({list})' , 6798see_lua =false , 6799} , 6800list2str ={ 6801args ={ 1 , 2 } , 6802base =1 , 6803desc =[=[ 6804Converts each codepoint in {list} to a UTF-8 character and 6805returns the concatenated string. Examples: >vim 6806echo list2str([32]) " returns " " 6807echo list2str([65, 66, 67]) " returns "ABC" 6808<The same can be done (slowly) with: >vim 6809echo join(map(list, {nr, val -> nr2char(val)}), '') 6810<|str2list()| does the opposite. 6811 6812UTF-8 encoding is always used, {utf8} option has no effect, 6813and exists only for backwards-compatibility. 6814With UTF-8 composing characters work as expected: >vim 6815echo list2str([97, 769]) " returns "á" 6816< 6817Returns an empty string on error. 6818 6819]=] , 6820name ='list2str' , 6821params ={ { 'list' , 'any[]' } , { 'utf8' , 'boolean' } } , 6822returns ='string' , 6823signature ='list2str({list} [, {utf8}])' , 6824see_lua =false , 6825} , 6826localtime ={ 6827desc =[=[ 6828Return the current time, measured as seconds since 1st Jan 68291970. See also |strftime()|, |strptime()| and |getftime()|. 6830]=] , 6831name ='localtime' , 6832params ={} , 6833returns ='integer' , 6834signature ='localtime()' , 6835see_lua ={ '|os.time()|' } , 6836} , 6837log ={ 6838args =1 , 6839base =1 , 6840desc =[=[ 6841Return the natural logarithm (base e) of {expr} as a |Float|. 6842{expr} must evaluate to a |Float| or a |Number| in the range 6843(0, inf]. 6844Returns 0.0 if {expr} is not a |Float| or a |Number|. 6845Examples: >vim 6846echo log(10) 6847< 2.302585 >vim 6848echo log(exp(5)) 6849< 5.0 6850 6851]=] , 6852func_float ='log' , 6853name ='log' , 6854params ={ { 'expr' , 'number' } } , 6855returns ='number' , 6856signature ='log({expr})' , 6857see_lua ={ '|math.log()|' } , 6858} , 6859log10 ={ 6860args =1 , 6861base =1 , 6862desc =[=[ 6863Return the logarithm of Float {expr} to base 10 as a |Float|. 6864{expr} must evaluate to a |Float| or a |Number|. 6865Returns 0.0 if {expr} is not a |Float| or a |Number|. 6866Examples: >vim 6867echo log10(1000) 6868< 3.0 >vim 6869echo log10(0.01) 6870< -2.0 6871 6872]=] , 6873func_float ='log10' , 6874name ='log10' , 6875params ={ { 'expr' , 'number' } } , 6876returns ='number' , 6877signature ='log10({expr})' , 6878see_lua ={ '|math.log10()|' } , 6879} , 6880luaeval ={ 6881args ={ 1 , 2 } , 6882base =1 , 6883desc =[=[ 6884Evaluate Lua expression {expr} and return its result converted 6885to Vim data structures. See |lua-eval| for details. 6886 6887See also |v:lua-call|. 6888 6889]=] , 6890lua =false , 6891name ='luaeval' , 6892params ={ { 'expr' , 'string' } , { 'expr' , 'any[]' } } , 6893signature ='luaeval({expr} [, {expr}])' , 6894see_lua ={ 'plain Lua expressions and values directly' } , 6895} , 6896map ={ 6897args =2 , 6898base =1 , 6899desc =[=[ 6900{expr1} must be a |List|, |String|, |Blob| or |Dictionary|. 6901When {expr1} is a |List| or |Dictionary|, replace each 6902item in {expr1} with the result of evaluating {expr2}. 6903For a |Blob| each byte is replaced. 6904For a |String|, each character, including composing 6905characters, is replaced. 6906If the item type changes you may want to use |mapnew()| to 6907create a new List or Dictionary. 6908 6909{expr2} must be a |String| or |Funcref|. 6910 6911If {expr2} is a |String|, inside {expr2} |v:val| has the value 6912of the current item. For a |Dictionary| |v:key| has the key 6913of the current item and for a |List| |v:key| has the index of 6914the current item. For a |Blob| |v:key| has the index of the 6915current byte. For a |String| |v:key| has the index of the 6916current character. 6917Example: >vim 6918call map(mylist, '"> " .. v:val .. " <"') 6919<This puts "> " before and " <" after each item in "mylist". 6920 6921Note that {expr2} is the result of an expression and is then 6922used as an expression again. Often it is good to use a 6923|literal-string| to avoid having to double backslashes. You 6924still have to double single (') quotes, though. 6925 6926If {expr2} is a |Funcref| it is called with two arguments: 69271. The key or the index of the current item. 69282. the value of the current item. 6929The function must return the new value of the item. Example 6930that changes each value by "key-value": >vim 6931func KeyValue(key, val) 6932return a:key .. '-' .. a:val 6933endfunc 6934call map(myDict, function('KeyValue')) 6935<It is shorter when using a |lambda|: >vim 6936call map(myDict, {key, val -> key .. '-' .. val}) 6937<If you do not use "val" you can leave it out: >vim 6938call map(myDict, {key -> 'item: ' .. key}) 6939<If you do not use "key" you can use a short name: >vim 6940call map(myDict, {_, val -> 'item: ' .. val}) 6941< 6942The operation is done in-place for a |List| and |Dictionary|. 6943If you want it to remain unmodified make a copy first: >vim 6944let tlist = map(copy(mylist), ' v:val .. "\t"') 6945 6946<Returns {expr1}, the |List| or |Dictionary| that was filtered, 6947or a new |Blob| or |String|. 6948When an error is encountered while evaluating {expr2} no 6949further items in {expr1} are processed. 6950When {expr2} is a Funcref errors inside a function are 6951ignored, unless it was defined with the "abort" flag. 6952 6953]=] , 6954name ='map' , 6955params ={ { 'expr1' , 'string|table|any[]' } , { 'expr2' , 'string|function' } } , 6956signature ='map({expr1}, {expr2})' , 6957see_lua ={ 6958'|vim.tbl_map()| for array-like tables; dict, string, blob, and in-place behavior differ' , 6959} , 6960} , 6961maparg ={ 6962args ={ 1 , 4 } , 6963base =1 , 6964desc =[=[ 6965When {dict} is omitted or zero: Return the rhs of mapping 6966{name} in mode {mode}. The returned String has special 6967characters translated like in the output of the ":map" command 6968listing. When {dict} is TRUE a dictionary is returned, see 6969below. To get a list of all mappings see |maplist()|. 6970 6971When there is no mapping for {name}, an empty String is 6972returned if {dict} is FALSE, otherwise returns an empty Dict. 6973When the mapping for {name} is empty, then "<Nop>" is 6974returned. 6975 6976The {name} can have special key names, like in the ":map" 6977command. 6978 6979{mode} can be one of these strings: 6980"n" Normal 6981"v" Visual (including Select) 6982"o" Operator-pending 6983"i" Insert 6984"c" Cmd-line 6985"s" Select 6986"x" Visual 6987"l" langmap |language-mapping| 6988"t" Terminal 6989"" Normal, Visual and Operator-pending 6990When {mode} is omitted, the modes for "" are used. 6991 6992When {abbr} is there and it is |TRUE| use abbreviations 6993instead of mappings. 6994 6995When {dict} is |TRUE|, return a dictionary describing the 6996mapping, with these items: *mapping-dict* 6997"lhs" The {lhs} of the mapping as it would be typed 6998"lhsraw" The {lhs} of the mapping as raw bytes 6999"lhsrawalt" The {lhs} of the mapping as raw bytes, alternate 7000form, only present when it differs from "lhsraw" 7001"rhs" The {rhs} of the mapping as typed. 7002"callback" Lua function, if RHS was defined as such. 7003"silent" 1 for a |:map-silent| mapping, else 0. 7004"noremap" 1 if the {rhs} of the mapping is not remappable. 7005"script" 1 if mapping was defined with <script>. 7006"expr" 1 for an expression mapping (|:map-<expr>|). 7007"buffer" 1 for a buffer local mapping (|:map-local|). 7008"mode" Modes for which the mapping is defined. In 7009addition to the modes mentioned above, these 7010characters will be used: 7011" " Normal, Visual and Operator-pending 7012"!" Insert and Commandline mode 7013(|mapmode-ic|) 7014"sid" The script local ID, used for <sid> mappings 7015(|<SID>|). Negative for special contexts. 7016"scriptversion" The version of the script, always 1. 7017"lnum" The line number in "sid", zero if unknown. 7018"nowait" Do not wait for other, longer mappings. 7019(|:map-<nowait>|). 7020"abbr" True if this is an |abbreviation|. 7021"mode_bits" Nvim's internal binary representation of "mode". 7022|mapset()| ignores this; only "mode" is used. 7023See |maplist()| for usage examples. The values 7024are from src/nvim/state_defs.h and may change in 7025the future. 7026 7027The dictionary can be used to restore a mapping with 7028|mapset()|. 7029 7030The mappings local to the current buffer are checked first, 7031then the global mappings. 7032This function can be used to map a key even when it's already 7033mapped, and have it do the original mapping too. Sketch: >vim 7034exe 'nnoremap <Tab> ==' .. maparg('<Tab>', 'n') 7035< 7036 7037]=] , 7038name ='maparg' , 7039params ={ 7040{ 'name' , 'string' } , 7041{ 'mode' , 'string' } , 7042{ 'abbr' , 'boolean' } , 7043{ 'dict' , 'false' } , 7044} , 7045signature ='maparg({name} [, {mode} [, {abbr} [, {dict}]]])' , 7046returns ='string' , 7047} , 7048maparg__1 ={ 7049args ={ 4 } , 7050base =1 , 7051name ='maparg' , 7052params ={ 7053{ 'name' , 'string' } , 7054{ 'mode' , 'string' } , 7055{ 'abbr' , 'boolean' } , 7056{ 'dict' , 'true' } , 7057} , 7058returns ='table<string,any>' , 7059} , 7060mapcheck ={ 7061args ={ 1 , 3 } , 7062base =1 , 7063desc =[=[ 7064Check if there is a mapping that matches with {name} in mode 7065{mode}. See |maparg()| for {mode} and special names in 7066{name}. 7067When {abbr} is there and it is non-zero use abbreviations 7068instead of mappings. 7069A match happens with a mapping that starts with {name} and 7070with a mapping which is equal to the start of {name}. 7071 7072matches mapping "a" "ab" "abc" ~ 7073mapcheck("a") yes yes yes 7074mapcheck("abc") yes yes yes 7075mapcheck("ax") yes no no 7076mapcheck("b") no no no 7077 7078The difference with |maparg()| is that mapcheck() finds a 7079mapping that matches with {name}, while |maparg()| only finds a 7080mapping for {name} exactly. 7081When there is no mapping that starts with {name}, an empty 7082String is returned. If there is one, the RHS of that mapping 7083is returned. If there are several mappings that start with 7084{name}, the RHS of one of them is returned. This will be 7085"<Nop>" if the RHS is empty. 7086The mappings local to the current buffer are checked first, 7087then the global mappings. 7088This function can be used to check if a mapping can be added 7089without being ambiguous. Example: >vim 7090if mapcheck("_vv") == "" 7091map _vv :set guifont=7x13<CR> 7092endif 7093<This avoids adding the "_vv" mapping when there already is a 7094mapping for "_v" or for "_vvv". 7095 7096]=] , 7097name ='mapcheck' , 7098params ={ { 'name' , 'string' } , { 'mode' , 'string' } , { 'abbr' , 'boolean' } } , 7099signature ='mapcheck({name} [, {mode} [, {abbr}]])' , 7100} , 7101maplist ={ 7102args ={ 0 , 1 } , 7103desc =[[ 7104Returns a |List| of all mappings. Each List item is a |Dict|, 7105the same as what is returned by |maparg()|, see 7106|mapping-dict|. When {abbr} is there and it is |TRUE| use 7107abbreviations instead of mappings. 7108 7109Example to show all mappings with "MultiMatch" in rhs: >vim 7110echo maplist()->filter({_, m -> 7111\ match(get(m, 'rhs', ''), 'MultiMatch') >= 0 7112\ }) 7113<It can be tricky to find mappings for particular |:map-modes|. 7114|mapping-dict|'s "mode_bits" can simplify this. For example, 7115the mode_bits for Normal, Insert or Command-line modes are 71160x19. To find all the mappings available in those modes you 7117can do: >vim 7118let saved_maps = [] 7119for m in maplist() 7120if and(m.mode_bits, 0x19) != 0 7121eval saved_maps->add(m) 7122endif 7123endfor 7124echo saved_maps->mapnew({_, m -> m.lhs}) 7125<The values of the mode_bits are defined in Nvim's 7126src/nvim/state_defs.h file and they can be discovered at 7127runtime using |:map-commands| and "maplist()". Example: >vim 7128omap xyzzy <Nop> 7129let op_bit = maplist()->filter( 7130\ {_, m -> m.lhs == 'xyzzy'})[0].mode_bits 7131ounmap xyzzy 7132echo printf("Operator-pending mode bit: 0x%x", op_bit) 7133< 7134]] , 7135name ='maplist' , 7136params ={ { 'abbr' , '0|1' } } , 7137returns ='table[]' , 7138signature ='maplist([{abbr}])' , 7139} , 7140mapnew ={ 7141args =2 , 7142base =1 , 7143desc =[=[ 7144Like |map()| but instead of replacing items in {expr1} a new 7145List or Dictionary is created and returned. {expr1} remains 7146unchanged. Items can still be changed by {expr2}, if you 7147don't want that use |deepcopy()| first. 7148]=] , 7149name ='mapnew' , 7150params ={ { 'expr1' , 'any' } , { 'expr2' , 'any' } } , 7151signature ='mapnew({expr1}, {expr2})' , 7152see_lua ={ 7153'|vim.tbl_map()| for tables; string, blob, and `v:key` callback behavior differ' , 7154} , 7155} , 7156mapset ={ 7157args ={ 1 , 3 } , 7158base =1 , 7159name ='mapset' , 7160params ={ { 'mode' , 'string' } , { 'abbr' , 'boolean' } , { 'dict' , 'table<string,any>' } } , 7161signature ='mapset({mode}, {abbr}, {dict})' , 7162} , 7163mapset__1 ={ 7164args ={ 1 , 3 } , 7165base =1 , 7166desc =[=[ 7167Restore a mapping from a dictionary, possibly returned by 7168|maparg()| or |maplist()|. A buffer mapping, when dict.buffer 7169is true, is set on the current buffer; it is up to the caller 7170to ensure that the intended buffer is the current buffer. 7171This feature allows copying mappings from one buffer to 7172another. 7173The dict.mode value may restore a single mapping that covers 7174more than one mode, like with mode values of '!', ' ', "nox", 7175or 'v'. *E1276* 7176 7177In the first form, {mode} and {abbr} should be the same as 7178for the call to |maparg()|. *E460* 7179{mode} is used to define the mode in which the mapping is set, 7180not the "mode" entry in {dict}. 7181Example for saving and restoring a mapping: >vim 7182let save_map = maparg('K', 'n', 0, 1) 7183nnoremap K somethingelse 7184" ... 7185call mapset('n', 0, save_map) 7186<Note that if you are going to replace a map in several modes, 7187e.g. with `:map!`, you need to save/restore the mapping for 7188all of them, when they might differ. 7189 7190In the second form, with {dict} as the only argument, mode 7191and abbr are taken from the dict. 7192Example: >vim 7193let save_maps = maplist()->filter( 7194\ {_, m -> m.lhs == 'K'}) 7195nnoremap K somethingelse 7196cnoremap K somethingelse2 7197" ... 7198unmap K 7199for d in save_maps 7200call mapset(d) 7201endfor 7202< 7203]=] , 7204name ='mapset' , 7205params ={ { 'dict' , 'table<string,any>' } } , 7206signature ='mapset({dict})' , 7207} , 7208match ={ 7209args ={ 2 , 4 } , 7210base =1 , 7211desc =[=[ 7212When {expr} is a |List| then this returns the index of the 7213first item where {pat} matches. Each item is used as a 7214String, |Lists| and |Dictionaries| are used as echoed. 7215 7216Otherwise, {expr} is used as a String. The result is a 7217Number, which gives the index (byte offset) in {expr} where 7218{pat} matches. 7219 7220A match at the first character or |List| item returns zero. 7221If there is no match -1 is returned. 7222 7223For getting submatches see |matchlist()|. 7224Example: >vim 7225echo match("testing", "ing") " results in 4 7226echo match([1, 'x'], '\a') " results in 1 7227<See |string-match| for how {pat} is used. 7228*strpbrk()* 7229Vim doesn't have a strpbrk() function. But you can do: >vim 7230let sepidx = match(line, '[.,;: \t]') 7231< *strcasestr()* 7232Vim doesn't have a strcasestr() function. But you can add 7233"\c" to the pattern to ignore case: >vim 7234let idx = match(haystack, '\cneedle') 7235< 7236If {start} is given, the search starts from byte index 7237{start} in a String or item {start} in a |List|. 7238The result, however, is still the index counted from the 7239first character/item. Example: >vim 7240echo match("testing", "ing", 2) 7241<result is again "4". >vim 7242echo match("testing", "ing", 4) 7243<result is again "4". >vim 7244echo match("testing", "t", 2) 7245<result is "3". 7246For a String, if {start} > 0 then it is like the string starts 7247{start} bytes later, thus "^" will match at {start}. Except 7248when {count} is given, then it's like matches before the 7249{start} byte are ignored (this is a bit complicated to keep it 7250backwards compatible). 7251For a String, if {start} < 0, it will be set to 0. For a list 7252the index is counted from the end. 7253If {start} is out of range ({start} > strlen({expr}) for a 7254String or {start} > len({expr}) for a |List|) -1 is returned. 7255 7256When {count} is given use the {count}th match. When a match 7257is found in a String the search for the next one starts one 7258character further. Thus this example results in 1: >vim 7259echo match("testing", "..", 0, 2) 7260<In a |List| the search continues in the next item. 7261Note that when {count} is added the way {start} works changes, 7262see above. 7263 7264*match-pattern* 7265See |pattern| for the patterns that are accepted. 7266The 'ignorecase' option is used to set the ignore-caseness of 7267the pattern. 'smartcase' is NOT used. The matching is always 7268done like 'magic' is set and 'cpoptions' is empty. 7269Note that a match at the start is preferred, thus when the 7270pattern is using "*" (any number of matches) it tends to find 7271zero matches at the start instead of a number of matches 7272further down in the text. 7273 7274]=] , 7275name ='match' , 7276params ={ 7277{ 'expr' , 'string|any[]' } , 7278{ 'pat' , 'string' } , 7279{ 'start' , 'integer' } , 7280{ 'count' , 'integer' } , 7281} , 7282signature ='match({expr}, {pat} [, {start} [, {count}]])' , 7283returns ='integer' , 7284} , 7285matchadd ={ 7286args ={ 2 , 5 } , 7287base =1 , 7288desc =[=[ 7289Defines a pattern to be highlighted in the current window (a 7290"match"). It will be highlighted with {group}. Returns an 7291identification number (ID), which can be used to delete the 7292match using |matchdelete()|. The ID is bound to the window. 7293Matching is case sensitive and magic, unless case sensitivity 7294or magicness are explicitly overridden in {pattern}. The 7295'magic', 'smartcase' and 'ignorecase' options are not used. 7296The "Conceal" value is special, it causes the match to be 7297concealed. 7298 7299The optional {priority} argument assigns a priority to the 7300match. A match with a high priority will have its 7301highlighting overrule that of a match with a lower priority. 7302A priority is specified as an integer (negative numbers are no 7303exception). If the {priority} argument is not specified, the 7304default priority is 10. The priority of 'hlsearch' is zero, 7305hence all matches with a priority greater than zero will 7306overrule it. Syntax highlighting (see 'syntax') is a separate 7307mechanism, and regardless of the chosen priority a match will 7308always overrule syntax highlighting. 7309 7310The optional {id} argument allows the request for a specific 7311match ID. If a specified ID is already taken, an error 7312message will appear and the match will not be added. An ID 7313is specified as a positive integer (zero excluded). IDs 1, 2 7314and 3 are reserved for |:match|, |:2match| and |:3match|, 7315respectively. 3 is reserved for use by the |matchparen| 7316plugin. 7317If the {id} argument is not specified or -1, |matchadd()| 7318automatically chooses a free ID, which is at least 1000. 7319 7320The optional {dict} argument allows for further custom 7321values. Currently this is used to specify a match specific 7322conceal character that will be shown for |hl-Conceal| 7323highlighted matches. The dict can have the following members: 7324 7325conceal Special character to show instead of the 7326match (only for |hl-Conceal| highlighted 7327matches, see |:syn-cchar|) 7328window Use this |window-number| or |window-ID| instead 7329of the current window. 7330 7331The number of matches is not limited, as it is the case with 7332the |:match| commands. 7333 7334Returns -1 on error. 7335 7336Example: >vim 7337highlight MyGroup ctermbg=green guibg=green 7338let m = matchadd("MyGroup", "TODO") 7339<Deletion of the pattern: >vim 7340call matchdelete(m) 7341 7342<A list of matches defined by |matchadd()| and |:match| are 7343available from |getmatches()|. All matches can be deleted in 7344one operation by |clearmatches()|. 7345 7346]=] , 7347name ='matchadd' , 7348params ={ 7349{ 'group' , 'integer|string' } , 7350{ 'pattern' , 'string' } , 7351{ 'priority' , 'integer' } , 7352{ 'id' , 'integer' } , 7353{ 'dict' , 'table' } , 7354} , 7355signature ='matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]])' , 7356tags ={ 'E798' , 'E799' , 'E801' , 'E957' } , 7357returns ='integer' , 7358} , 7359matchaddpos ={ 7360args ={ 2 , 5 } , 7361base =1 , 7362desc =[=[ 7363Same as |matchadd()|, but requires a list of positions {pos} 7364instead of a pattern. This command is faster than |matchadd()| 7365because it does not handle regular expressions and it sets 7366buffer line boundaries to redraw screen. It is supposed to be 7367used when fast match additions and deletions are required, for 7368example to highlight matching parentheses. 7369*E5030* *E5031* 7370{pos} is a list of positions. Each position can be one of 7371these: 7372- A number. This whole line will be highlighted. The first 7373line has number 1. 7374- A list with one number, e.g., [23]. The whole line with 7375this number will be highlighted. 7376- A list with two numbers, e.g., [23, 11]. The first number 7377is the line number, the second one is the column number 7378(first column is 1, the value must correspond to the byte 7379index as |col()| would return). The character at this 7380position will be highlighted. 7381- A list with three numbers, e.g., [23, 11, 3]. As above, but 7382the third number gives the length of the highlight in bytes. 7383 7384Entries with zero and negative line numbers are silently 7385ignored, as well as entries with negative column numbers and 7386lengths. 7387 7388Returns -1 on error. 7389 7390Example: >vim 7391highlight MyGroup ctermbg=green guibg=green 7392let m = matchaddpos("MyGroup", [[23, 24], 34]) 7393<Deletion of the pattern: >vim 7394call matchdelete(m) 7395 7396<Matches added by |matchaddpos()| are returned by 7397|getmatches()|. 7398 7399]=] , 7400name ='matchaddpos' , 7401params ={ 7402{ 'group' , 'integer|string' } , 7403{ 'pos' , 'any[]' } , 7404{ 'priority' , 'integer' } , 7405{ 'id' , 'integer' } , 7406{ 'dict' , 'table' } , 7407} , 7408signature ='matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]])' , 7409returns ='integer|table' , 7410} , 7411matcharg ={ 7412args =1 , 7413base =1 , 7414desc =[=[ 7415Selects the {nr} match item, as set with a |:match|, 7416|:2match| or |:3match| command. 7417Return a |List| with two elements: 7418The name of the highlight group used 7419The pattern used. 7420When {nr} is not 1, 2 or 3 returns an empty |List|. 7421When there is no match item set returns ['', '']. 7422This is useful to save and restore a |:match|. 7423Highlighting matches using the |:match| commands are limited 7424to three matches. |matchadd()| does not have this limitation. 7425 7426]=] , 7427name ='matcharg' , 7428params ={ { 'nr' , 'integer' } } , 7429signature ='matcharg({nr})' , 7430returns ='string[]' , 7431} , 7432matchbufline ={ 7433args ={ 4 , 5 } , 7434base =1 , 7435desc =[=[ 7436Returns the |List| of matches in lines from {lnum} to {end} in 7437buffer {buf} where {pat} matches. 7438 7439{lnum} and {end} can either be a line number or the string "$" 7440to refer to the last line in {buf}. 7441 7442The {dict} argument supports following items: 7443submatches include submatch information (|/\(|) 7444 7445For each match, a |Dict| with the following items is returned: 7446byteidx starting byte index of the match 7447lnum line number where there is a match 7448text matched string 7449Note that there can be multiple matches in a single line. 7450 7451This function works only for loaded buffers. First call 7452|bufload()| if needed. 7453 7454See |match-pattern| for information about the effect of some 7455option settings on the pattern. 7456 7457When {buf} is not a valid buffer, the buffer is not loaded or 7458{lnum} or {end} is not valid then an error is given and an 7459empty |List| is returned. 7460 7461Examples: >vim 7462" Assuming line 3 in buffer 5 contains "a" 7463echo matchbufline(5, '\<\k\+\>', 3, 3) 7464< `[{'lnum': 3, 'byteidx': 0, 'text': 'a'}]` >vim 7465" Assuming line 4 in buffer 10 contains "tik tok" 7466echo matchbufline(10, '\<\k\+\>', 1, 4) 7467< `[{'lnum': 4, 'byteidx': 0, 'text': 'tik'}, {'lnum': 4, 'byteidx': 4, 'text': 'tok'}]` 7468 7469If {submatch} is present and is v:true, then submatches like 7470"\1", "\2", etc. are also returned. Example: >vim 7471" Assuming line 2 in buffer 2 contains "acd" 7472echo matchbufline(2, '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2, 2 7473\ {'submatches': v:true}) 7474< `[{'lnum': 2, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]` 7475The "submatches" List always contains 9 items. If a submatch 7476is not found, then an empty string is returned for that 7477submatch. 7478]=] , 7479name ='matchbufline' , 7480params ={ 7481{ 'buf' , 'string|integer' } , 7482{ 'pat' , 'string' } , 7483{ 'lnum' , 'string|integer' } , 7484{ 'end' , 'string|integer' } , 7485{ 'dict' , 'table' } , 7486} , 7487signature ='matchbufline({buf}, {pat}, {lnum}, {end}, [, {dict}])' , 7488returns ='string[]' , 7489} , 7490matchdelete ={ 7491args ={ 1 , 2 } , 7492base =1 , 7493desc =[=[ 7494Deletes a match with ID {id} previously defined by |matchadd()| 7495or one of the |:match| commands. Returns 0 if successful, 7496otherwise -1. See example for |matchadd()|. All matches can 7497be deleted in one operation by |clearmatches()|. 7498{win} (if given) is a |window-number| or |window-ID|. 7499 7500]=] , 7501name ='matchdelete' , 7502params ={ { 'id' , 'integer' } , { 'win' , 'integer' } } , 7503signature ='matchdelete({id} [, {win}])' , 7504tags ={ 'E802' , 'E803' } , 7505} , 7506matchend ={ 7507args ={ 2 , 4 } , 7508base =1 , 7509desc =[=[ 7510Same as |match()|, but return the index of first character 7511after the match. Example: >vim 7512echo matchend("testing", "ing") 7513<results in "7". 7514*strspn()* *strcspn()* 7515Vim doesn't have a strspn() or strcspn() function, but you can 7516do it with matchend(): >vim 7517let span = matchend(line, '[a-zA-Z]') 7518let span = matchend(line, '[^a-zA-Z]') 7519<Except that -1 is returned when there are no matches. 7520 7521The {start}, if given, has the same meaning as for |match()|. >vim 7522echo matchend("testing", "ing", 2) 7523<results in "7". >vim 7524echo matchend("testing", "ing", 5) 7525<result is "-1". 7526When {expr} is a |List| the result is equal to |match()|. 7527 7528]=] , 7529name ='matchend' , 7530params ={ 7531{ 'expr' , 'any' } , 7532{ 'pat' , 'string' } , 7533{ 'start' , 'integer' } , 7534{ 'count' , 'integer' } , 7535} , 7536signature ='matchend({expr}, {pat} [, {start} [, {count}]])' , 7537returns ='integer' , 7538} , 7539matchfuzzy ={ 7540args ={ 2 , 3 } , 7541base =1 , 7542desc =[=[ 7543If {list} is a list of strings, then returns a |List| with all 7544the strings in {list} that fuzzy match {str}. The strings in 7545the returned list are sorted based on the matching score. 7546 7547The optional {dict} argument always supports the following 7548items: 7549matchseq When this item is present return only matches 7550that contain the characters in {str} in the 7551given sequence. 7552limit Maximum number of matches in {list} to be 7553returned. Zero means no limit. 7554 7555If {list} is a list of dictionaries, then the optional {dict} 7556argument supports the following additional items: 7557key Key of the item which is fuzzy matched against 7558{str}. The value of this item should be a 7559string. 7560text_cb |Funcref| that will be called for every item 7561in {list} to get the text for fuzzy matching. 7562This should accept a dictionary item as the 7563argument and return the text for that item to 7564use for fuzzy matching. 7565 7566{str} is treated as a literal string and regular expression 7567matching is NOT supported. Only the first 1024 characters of 7568{str} and of each item in {list} are used for matching; 7569characters beyond that are ignored. 7570 7571When {str} has multiple words each separated by white space, 7572then the list of strings that have all the words is returned. 7573 7574If there are no matching strings or there is an error, then an 7575empty list is returned. 7576 7577When {limit} is given, matchfuzzy() will find up to this 7578number of matches in {list} and return them in sorted order. 7579 7580Refer to |fuzzy-matching| for more information about fuzzy 7581matching strings. 7582 7583Example: >vim 7584echo matchfuzzy(["clay", "crow"], "cay") 7585<results in ["clay"]. >vim 7586echo getbufinfo()->map({_, v -> v.name})->matchfuzzy("ndl") 7587<results in a list of buffer names fuzzy matching "ndl". >vim 7588echo getbufinfo()->matchfuzzy("ndl", {'key' : 'name'}) 7589<results in a list of buffer information dicts with buffer 7590names fuzzy matching "ndl". >vim 7591echo getbufinfo()->matchfuzzy("spl", 7592\ {'text_cb' : {v -> v.name}}) 7593<results in a list of buffer information dicts with buffer 7594names fuzzy matching "spl". >vim 7595echo v:oldfiles->matchfuzzy("test") 7596<results in a list of file names fuzzy matching "test". >vim 7597let l = readfile("buffer.c")->matchfuzzy("str") 7598<results in a list of lines in "buffer.c" fuzzy matching "str". >vim 7599echo ['one two', 'two one']->matchfuzzy('two one') 7600<results in `['two one', 'one two']` . >vim 7601echo ['one two', 'two one']->matchfuzzy('two one', 7602\ {'matchseq': 1}) 7603<results in `['two one']`. 7604]=] , 7605name ='matchfuzzy' , 7606params ={ { 'list' , 'any[]' } , { 'str' , 'string' } , { 'dict' , 'table' } } , 7607signature ='matchfuzzy({list}, {str} [, {dict}])' , 7608returns ='table' , 7609} , 7610matchfuzzypos ={ 7611args ={ 2 , 3 } , 7612base =1 , 7613desc =[=[ 7614Same as |matchfuzzy()|, but returns the list of matched 7615strings, the list of character positions where characters 7616in {str} matches and a list of matching scores. You can 7617use |byteidx()| to convert a character position to a byte 7618position. 7619 7620If {str} matches multiple times in a string, then only the 7621positions for the best match is returned. 7622 7623If there are no matching strings or there is an error, then a 7624list with three empty list items is returned. 7625 7626Example: >vim 7627echo matchfuzzypos(['testing'], 'tsg') 7628<results in [["testing"], [[0, 2, 6]], [99]] >vim 7629echo matchfuzzypos(['clay', 'lacy'], 'la') 7630<results in [["lacy", "clay"], [[0, 1], [1, 2]], [153, 133]] >vim 7631echo [{'text': 'hello', 'id' : 10}] 7632\ ->matchfuzzypos('ll', {'key' : 'text'}) 7633<results in `[[{"id": 10, "text": "hello"}], [[2, 3]], [127]]` 7634]=] , 7635name ='matchfuzzypos' , 7636params ={ { 'list' , 'any[]' } , { 'str' , 'string' } , { 'dict' , 'table' } } , 7637signature ='matchfuzzypos({list}, {str} [, {dict}])' , 7638returns ='table' , 7639} , 7640matchlist ={ 7641args ={ 2 , 4 } , 7642base =1 , 7643desc =[=[ 7644Same as |match()|, but return a |List|. The first item in the 7645list is the matched string, same as what |matchstr()| would 7646return. Following items are submatches, like "\1", "\2", etc. 7647in |:substitute|. When an optional submatch didn't match an 7648empty string is used. Example: >vim 7649echo matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)') 7650<Results in: ['acd', 'a', '', 'c', 'd', '', '', '', '', ''] 7651When there is no match an empty list is returned. 7652 7653You can pass in a List, but that is not very useful. 7654 7655]=] , 7656name ='matchlist' , 7657params ={ 7658{ 'expr' , 'any' } , 7659{ 'pat' , 'string' } , 7660{ 'start' , 'integer' } , 7661{ 'count' , 'integer' } , 7662} , 7663signature ='matchlist({expr}, {pat} [, {start} [, {count}]])' , 7664returns ='string[]' , 7665} , 7666matchstr ={ 7667args ={ 2 , 4 } , 7668base =1 , 7669desc =[=[ 7670Same as |match()|, but return the matched string. Example: >vim 7671echo matchstr("testing", "ing") 7672<results in "ing". 7673When there is no match "" is returned. 7674The {start}, if given, has the same meaning as for |match()|. >vim 7675echo matchstr("testing", "ing", 2) 7676<results in "ing". >vim 7677echo matchstr("testing", "ing", 5) 7678<result is "". 7679When {expr} is a |List| then the matching item is returned. 7680The type isn't changed, it's not necessarily a String. 7681 7682]=] , 7683name ='matchstr' , 7684params ={ 7685{ 'expr' , 'any' } , 7686{ 'pat' , 'string' } , 7687{ 'start' , 'integer' } , 7688{ 'count' , 'integer' } , 7689} , 7690signature ='matchstr({expr}, {pat} [, {start} [, {count}]])' , 7691returns ='string' , 7692} , 7693matchstrlist ={ 7694args ={ 2 , 3 } , 7695base =1 , 7696desc =[=[ 7697Returns the |List| of matches in {list} where {pat} matches. 7698{list} is a |List| of strings. {pat} is matched against each 7699string in {list}. 7700 7701The {dict} argument supports following items: 7702submatches include submatch information (|/\(|) 7703 7704For each match, a |Dict| with the following items is returned: 7705byteidx starting byte index of the match. 7706idx index in {list} of the match. 7707text matched string 7708submatches a List of submatches. Present only if 7709"submatches" is set to v:true in {dict}. 7710 7711See |match-pattern| for information about the effect of some 7712option settings on the pattern. 7713 7714Example: >vim 7715echo matchstrlist(['tik tok'], '\<\k\+\>') 7716< `[{'idx': 0, 'byteidx': 0, 'text': 'tik'}, {'idx': 0, 'byteidx': 4, 'text': 'tok'}]` >vim 7717echo matchstrlist(['a', 'b'], '\<\k\+\>') 7718< `[{'idx': 0, 'byteidx': 0, 'text': 'a'}, {'idx': 1, 'byteidx': 0, 'text': 'b'}]` 7719 7720If "submatches" is present and is v:true, then submatches like 7721"\1", "\2", etc. are also returned. Example: >vim 7722echo matchstrlist(['acd'], '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 7723\ #{submatches: v:true}) 7724< `[{'idx': 0, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]` 7725The "submatches" List always contains 9 items. If a submatch 7726is not found, then an empty string is returned for that 7727submatch. 7728]=] , 7729name ='matchstrlist' , 7730params ={ { 'list' , 'string[]' } , { 'pat' , 'string' } , { 'dict' , 'table' } } , 7731signature ='matchstrlist({list}, {pat} [, {dict}])' , 7732returns ='string[]' , 7733} , 7734matchstrpos ={ 7735args ={ 2 , 4 } , 7736base =1 , 7737desc =[=[ 7738Same as |matchstr()|, but return the matched string, the start 7739position and the end position of the match. Example: >vim 7740echo matchstrpos("testing", "ing") 7741<results in ["ing", 4, 7]. 7742When there is no match ["", -1, -1] is returned. 7743The {start}, if given, has the same meaning as for |match()|. >vim 7744echo matchstrpos("testing", "ing", 2) 7745<results in ["ing", 4, 7]. >vim 7746echo matchstrpos("testing", "ing", 5) 7747<result is ["", -1, -1]. 7748When {expr} is a |List| then the matching item, the index 7749of first item where {pat} matches, the start position and the 7750end position of the match are returned. >vim 7751echo matchstrpos([1, '__x'], '\a') 7752<result is ["x", 1, 2, 3]. 7753The type isn't changed, it's not necessarily a String. 7754 7755]=] , 7756name ='matchstrpos' , 7757params ={ 7758{ 'expr' , 'any' } , 7759{ 'pat' , 'string' } , 7760{ 'start' , 'integer' } , 7761{ 'count' , 'integer' } , 7762} , 7763signature ='matchstrpos({expr}, {pat} [, {start} [, {count}]])' , 7764returns ='table' , 7765} , 7766max ={ 7767args =1 , 7768base =1 , 7769desc =[=[ 7770Return the maximum value of all items in {expr}. Example: >vim 7771echo max([apples, pears, oranges]) 7772 7773<{expr} can be a |List| or a |Dictionary|. For a Dictionary, 7774it returns the maximum of all values in the Dictionary. 7775If {expr} is neither a List nor a Dictionary, or one of the 7776items in {expr} cannot be used as a Number this results in 7777an error. An empty |List| or |Dictionary| results in zero. 7778 7779]=] , 7780name ='max' , 7781params ={ { 'expr' , 'any' } } , 7782returns ='number' , 7783signature ='max({expr})' , 7784see_lua ={ 7785'|math.max()| with `unpack(expr)` for lists; dict values and empty inputs need custom handling' , 7786} , 7787} , 7788menu_get ={ 7789args ={ 1 , 2 } , 7790desc =[=[ 7791Returns a |List| of |Dictionaries| describing |menus| (defined 7792by |:menu|, |:amenu|, …), including |hidden-menus|. 7793 7794{path} matches a menu by name, or all menus if {path} is an 7795empty string. Example: >vim 7796echo menu_get('File','') 7797echo menu_get('') 7798< 7799{modes} is a string of zero or more modes (see |maparg()| or 7800|creating-menus| for the list of modes). "a" means "all". 7801 7802Example: >vim 7803nnoremenu &Test.Test inormal 7804inoremenu Test.Test insert 7805vnoremenu Test.Test x 7806echo menu_get("") 7807 7808<returns something like this: > 7809 7810[ { 7811"hidden": 0, 7812"name": "Test", 7813"priority": 500, 7814"shortcut": 84, 7815"submenus": [ { 7816"hidden": 0, 7817"mappings": { 7818i": { 7819"enabled": 1, 7820"noremap": 1, 7821"rhs": "insert", 7822"sid": 1, 7823"silent": 0 7824}, 7825n": { ... }, 7826s": { ... }, 7827v": { ... } 7828}, 7829"name": "Test", 7830"priority": 500, 7831"shortcut": 0 7832} ] 7833} ] 7834< 7835]=] , 7836name ='menu_get' , 7837params ={ { 'path' , 'string' } , { 'modes' , 'string' } } , 7838signature ='menu_get({path} [, {modes}])' , 7839} , 7840menu_info ={ 7841args ={ 1 , 2 } , 7842base =1 , 7843desc =[=[ 7844Return information about the specified menu {name} in 7845mode {mode}. The menu name should be specified without the 7846shortcut character ('&'). If {name} is "", then the top-level 7847menu names are returned. 7848 7849{mode} can be one of these strings: 7850"n" Normal 7851"v" Visual (including Select) 7852"o" Operator-pending 7853"i" Insert 7854"c" Cmd-line 7855"s" Select 7856"x" Visual 7857"t" Terminal-Job 7858"" Normal, Visual and Operator-pending 7859"!" Insert and Cmd-line 7860When {mode} is omitted, the modes for "" are used. 7861 7862Returns a |Dictionary| containing the following items: 7863accel menu item accelerator text |menu-text| 7864display display name (name without '&') 7865enabled v:true if this menu item is enabled 7866Refer to |:menu-enable| 7867icon name of the icon file (for toolbar) 7868|toolbar-icon| 7869iconidx index of a built-in icon 7870modes modes for which the menu is defined. In 7871addition to the modes mentioned above, these 7872characters will be used: 7873" " Normal, Visual and Operator-pending 7874name menu item name. 7875noremenu v:true if the {rhs} of the menu item is not 7876remappable else v:false. 7877priority menu order priority |menu-priority| 7878rhs right-hand-side of the menu item. The 7879returned string has special characters 7880translated like in the output of the ":menu" 7881command listing. When the {rhs} of a menu 7882item is empty, then "<Nop>" is returned. 7883script v:true if script-local remapping of {rhs} is 7884allowed else v:false. See |:menu-script|. 7885shortcut shortcut key (character after '&' in 7886the menu name) |menu-shortcut| 7887silent v:true if the menu item is created 7888with <silent> argument |:menu-silent| 7889submenus |List| containing the names of 7890all the submenus. Present only if the menu 7891item has submenus. 7892 7893Returns an empty dictionary if the menu item is not found. 7894 7895Examples: >vim 7896echo menu_info('Edit.Cut') 7897echo menu_info('File.Save', 'n') 7898 7899" Display the entire menu hierarchy in a buffer 7900func ShowMenu(name, pfx) 7901let m = menu_info(a:name) 7902call append(line('$'), a:pfx .. m.display) 7903for child in m->get('submenus', []) 7904call ShowMenu(a:name .. '.' .. escape(child, '.'), 7905\ a:pfx .. ' ') 7906endfor 7907endfunc 7908new 7909for topmenu in menu_info('').submenus 7910call ShowMenu(topmenu, '') 7911endfor 7912< 7913]=] , 7914name ='menu_info' , 7915params ={ { 'name' , 'string' } , { 'mode' , 'string' } } , 7916signature ='menu_info({name} [, {mode}])' , 7917} , 7918min ={ 7919args =1 , 7920base =1 , 7921desc =[=[ 7922Return the minimum value of all items in {expr}. Example: >vim 7923echo min([apples, pears, oranges]) 7924 7925<{expr} can be a |List| or a |Dictionary|. For a Dictionary, 7926it returns the minimum of all values in the Dictionary. 7927If {expr} is neither a List nor a Dictionary, or one of the 7928items in {expr} cannot be used as a Number this results in 7929an error. An empty |List| or |Dictionary| results in zero. 7930 7931]=] , 7932name ='min' , 7933params ={ { 'expr' , 'any' } } , 7934returns ='number' , 7935signature ='min({expr})' , 7936see_lua ={ 7937'|math.min()| with `unpack(expr)` for lists; dict values and empty inputs need custom handling' , 7938} , 7939} , 7940mkdir ={ 7941args ={ 1 , 3 } , 7942base =1 , 7943desc =[=[ 7944Create directory {name}. 7945 7946When {flags} is present it must be a string. An empty string 7947has no effect. 7948 7949{flags} can contain these character flags: 7950"p" intermediate directories will be created as necessary 7951"D" {name} will be deleted at the end of the current 7952function, but not recursively |:defer| 7953"R" {name} will be deleted recursively at the end of the 7954current function |:defer| 7955 7956Note that when {name} has more than one part and "p" is used 7957some directories may already exist. Only the first one that 7958is created and what it contains is scheduled to be deleted. 7959E.g. when using: >vim 7960call mkdir('subdir/tmp/autoload', 'pR') 7961<and "subdir" already exists then "subdir/tmp" will be 7962scheduled for deletion, like with: >vim 7963defer delete('subdir/tmp', 'rf') 7964< 7965If {prot} is given it is used to set the protection bits of 7966the new directory. The default is 0o755 (rwxr-xr-x: r/w for 7967the user, readable for others). Use 0o700 to make it 7968unreadable for others. This is used for the newly created 7969directories. Note: umask is applied to {prot} (on Unix). 7970Example: >vim 7971call mkdir($HOME .. "/tmp/foo/bar", "p", 0o700) 7972 7973<This function is not available in the |sandbox|. 7974 7975If you try to create an existing directory with {flags} set to 7976"p" mkdir() will silently exit. 7977 7978The function result is a Number, which is TRUE if the call was 7979successful or FALSE if the directory creation failed or partly 7980failed. 7981 7982]=] , 7983name ='mkdir' , 7984params ={ { 'name' , 'string' } , { 'flags' , 'string' } , { 'prot' , 'string' } } , 7985returns ='integer' , 7986signature ='mkdir({name} [, {flags} [, {prot}]])' , 7987tags ={ 'E739' } , 7988see_lua ={ 7989'|vim.fs.mkdir()|; `"D"`, `"R"`, and return semantics differ' , 7990} , 7991} , 7992mode ={ 7993args ={ 0 , 1 } , 7994base =1 , 7995desc =[=[ 7996Return a string that indicates the current mode. 7997If {expr} is supplied and it evaluates to a non-zero Number or 7998a non-empty String (|non-zero-arg|), then the full mode is 7999returned, otherwise only the first letter is returned. 8000Also see |state()|. 8001 8002n Normal 8003no Operator-pending 8004nov Operator-pending (forced charwise |o_v|) 8005noV Operator-pending (forced linewise |o_V|) 8006noCTRL-V Operator-pending (forced blockwise |o_CTRL-V|) 8007CTRL-V is one character 8008niI Normal using |i_CTRL-O| in |Insert-mode| 8009niR Normal using |i_CTRL-O| in |Replace-mode| 8010niV Normal using |i_CTRL-O| in |Virtual-Replace-mode| 8011nt Normal in |terminal-emulator| (insert goes to 8012Terminal mode) 8013ntT Normal using |t_CTRL-\_CTRL-O| in |Terminal-mode| 8014v Visual by character 8015vs Visual by character using |v_CTRL-O| in Select mode 8016V Visual by line 8017Vs Visual by line using |v_CTRL-O| in Select mode 8018CTRL-V Visual blockwise 8019CTRL-Vs Visual blockwise using |v_CTRL-O| in Select mode 8020s Select by character 8021S Select by line 8022CTRL-S Select blockwise 8023i Insert 8024ic Insert mode completion |compl-generic| 8025ix Insert mode |i_CTRL-X| completion 8026R Replace |R| 8027Rc Replace mode completion |compl-generic| 8028Rx Replace mode |i_CTRL-X| completion 8029Rv Virtual Replace |gR| 8030Rvc Virtual Replace mode completion |compl-generic| 8031Rvx Virtual Replace mode |i_CTRL-X| completion 8032c Command-line editing 8033cr Command-line editing overstrike mode |c_<Insert>| 8034cv Non-interactive Ex mode |-es| 8035r Hit-enter prompt 8036rm The -- more -- prompt 8037r? A |:confirm| query of some sort 8038! Shell or external command is executing 8039t Terminal mode: keys go to the job 8040 8041This is useful in the 'statusline' option or RPC calls. In 8042most other places it always returns "c" or "n". 8043Note that in the future more modes and more specific modes may 8044be added. It's better not to compare the whole string but 8045only the leading character(s). 8046Also see |visualmode()|. 8047 8048]=] , 8049name ='mode' , 8050params ={ { 'expr' , 'any' } } , 8051signature ='mode([{expr}])' , 8052see_lua ={ 8053'|nvim_get_mode()|; use the `.mode` field. It always returns the full mode string, unlike |mode()| without a non-zero {expr}' , 8054} , 8055} , 8056msgpackdump ={ 8057args ={ 1 , 2 } , 8058desc =[=[ 8059Convert a list of Vimscript objects to msgpack. Returned value is a 8060|readfile()|-style list. When {type} contains "B", a |Blob| is 8061returned instead. Example: >vim 8062call writefile(msgpackdump([{}]), 'fname.mpack', 'b') 8063<or, using a |Blob|: >vim 8064call writefile(msgpackdump([{}], 'B'), 'fname.mpack') 8065< 8066This will write the single 0x80 byte to a `fname.mpack` file 8067(dictionary with zero items is represented by 0x80 byte in 8068messagepack). 8069 8070Limitations: *E5004* *E5005* 80711. |Funcref|s cannot be dumped. 80722. Containers that reference themselves cannot be dumped. 80733. Dictionary keys are always dumped as STR strings. 80744. Other strings and |Blob|s are always dumped as BIN strings. 80755. Points 3. and 4. do not apply to |msgpack-special-dict|s. 8076]=] , 8077name ='msgpackdump' , 8078params ={ { 'list' , 'any' } , { 'type' , 'any' } } , 8079signature ='msgpackdump({list} [, {type}])' , 8080see_lua ={ 8081'|vim.mpack.encode()|; list wrapping, return shape, and special-dict semantics differ' , 8082} , 8083} , 8084msgpackparse ={ 8085args =1 , 8086desc =[=[ 8087Convert a |readfile()|-style list or a |Blob| to a list of 8088Vimscript objects. 8089Example: >vim 8090let fname = expand('~/.config/nvim/shada/main.shada') 8091let mpack = readfile(fname, 'b') 8092let shada_objects = msgpackparse(mpack) 8093<This will read ~/.config/nvim/shada/main.shada file to 8094`shada_objects` list. 8095 8096Limitations: 80971. Mapping ordering is not preserved unless messagepack 8098mapping is dumped using generic mapping 8099(|msgpack-special-map|). 81002. Since the parser aims to preserve all data untouched 8101(except for 1.) some strings are parsed to 8102|msgpack-special-dict| format which is not convenient to 8103use. 8104*msgpack-special-dict* 8105Some messagepack strings may be parsed to special 8106dictionaries. Special dictionaries are dictionaries which 8107 81081. Contain exactly two keys: `_TYPE` and `_VAL`. 81092. `_TYPE` key is one of the types found in |v:msgpack_types| 8110variable. 81113. Value for `_VAL` has the following format (Key column 8112contains name of the key from |v:msgpack_types|): 8113 8114Key Value ~ 8115nil Zero, ignored when dumping. Not returned by 8116|msgpackparse()| since |v:null| was introduced. 8117boolean One or zero. When dumping it is only checked that 8118value is a |Number|. Not returned by |msgpackparse()| 8119since |v:true| and |v:false| were introduced. 8120integer |List| with four numbers: sign (-1 or 1), highest two 8121bits, number with bits from 62nd to 31st, lowest 31 8122bits. I.e. to get actual number one will need to use 8123code like > 8124_VAL[0] * ((_VAL[1] << 62) 8125& (_VAL[2] << 31) 8126& _VAL[3]) 8127< Special dictionary with this type will appear in 8128|msgpackparse()| output under one of the following 8129circumstances: 81301. |Number| is 32-bit and value is either above 8131INT32_MAX or below INT32_MIN. 81322. |Number| is 64-bit and value is above INT64_MAX. It 8133cannot possibly be below INT64_MIN because msgpack 8134C parser does not support such values. 8135float |Float|. This value cannot possibly appear in 8136|msgpackparse()| output. 8137string |String|, or |Blob| if binary string contains zero 8138byte. This value cannot appear in |msgpackparse()| 8139output since blobs were introduced. 8140array |List|. This value cannot appear in |msgpackparse()| 8141output. 8142*msgpack-special-map* 8143map |List| of |List|s with two items (key and value) each. 8144This value will appear in |msgpackparse()| output if 8145parsed mapping contains one of the following keys: 81461. Any key that is not a string (including keys which 8147are binary strings). 81482. String with NUL byte inside. 81493. Duplicate key. 8150ext |List| with two values: first is a signed integer 8151representing extension type. Second is 8152|readfile()|-style list of strings. 8153]=] , 8154name ='msgpackparse' , 8155params ={ { 'data' , 'any' } } , 8156signature ='msgpackparse({data})' , 8157see_lua ={ '|vim.mpack.decode()|; input and special-dict semantics differ' } , 8158} , 8159nextnonblank ={ 8160args =1 , 8161base =1 , 8162desc =[=[ 8163Return the line number of the first line at or below {lnum} 8164that is not blank. Example: >vim 8165if getline(nextnonblank(1)) =~ "Java" | endif 8166<When {lnum} is invalid or there is no non-blank line at or 8167below it, zero is returned. 8168{lnum} is used like with |getline()|. 8169See also |prevnonblank()|. 8170 8171]=] , 8172name ='nextnonblank' , 8173params ={ { 'lnum' , 'integer|string' } } , 8174returns ='integer' , 8175signature ='nextnonblank({lnum})' , 8176} , 8177nr2char ={ 8178args ={ 1 , 2 } , 8179base =1 , 8180desc =[=[ 8181Gets a UTF-8 string for a single codepoint {expr}. 8182Examples: >vim 8183echo nr2char(64) " returns '@' 8184echo nr2char(32) " returns ' ' 8185echo nr2char(300) " returns I with bow character 8186< 8187UTF-8 encoding is always used, {utf8} option has no effect, 8188and exists only for backwards-compatibility. 8189Note that a NUL character in the file is specified with 8190nr2char(10), because NULs are represented with newline 8191characters. nr2char(0) is a real NUL and terminates the 8192string, thus results in an empty string. 8193 8194]=] , 8195fast =true , 8196name ='nr2char' , 8197params ={ { 'expr' , 'integer' } , { 'utf8' , 'boolean' } } , 8198returns ='string' , 8199signature ='nr2char({expr} [, {utf8}])' , 8200see_lua ={ '|string.char()|: only works with ASCII' } , 8201} , 8202nvim_api__ ={ 8203args =1 , 8204base =1 , 8205desc =[=[ 8206Call nvim |api| functions. The type checking of arguments will 8207be stricter than for most other builtins. For instance, 8208if Integer is expected, a |Number| must be passed in, a 8209|String| will not be autoconverted. 8210Buffer numbers, as returned by |bufnr()| could be used as 8211first argument to nvim_buf_... functions. All functions 8212expecting an object (buffer, window or tabpage) can 8213also take the numerical value 0 to indicate the current 8214(focused) object. 8215]=] , 8216lua =false , 8217name ='nvim_...' , 8218params =VARARGS , 8219signature ='nvim_...({...})' , 8220tags ={ 'E5555' , 'eval-api' } , 8221see_lua ={ '|vim.api|' } , 8222} , 8223[ 'or' ] ={ 8224args =2 , 8225base =1 , 8226desc =[=[ 8227Bitwise OR on the two arguments. The arguments are converted 8228to a number. A List, Dict or Float argument causes an error. 8229Also see `and()` and `xor()`. 8230Example: >vim 8231let bits = or(bits, 0x80) 8232 8233<Rationale: The reason this is a function and not using the "|" 8234character like many languages, is that Vi has always used "|" 8235to separate commands. In many places it would not be clear if 8236"|" is an operator or a command separator. 8237]=] , 8238name ='or' , 8239params ={ { 'expr' , 'number' } , { 'expr' , 'number' } } , 8240signature ='or({expr}, {expr})' , 8241see_lua ={ '|bit.bor()|' } , 8242} , 8243pathshorten ={ 8244args ={ 1 , 2 } , 8245base =1 , 8246desc =[=[ 8247Shorten directory names in the path {path} and return the 8248result. The tail, the file name, is kept as-is. The other 8249components in the path are reduced to {len} letters in length. 8250If {len} is omitted or smaller than 1 then 1 is used (single 8251letters). Leading '~' and '.' characters are kept. Examples: >vim 8252echo pathshorten('~/.config/nvim/autoload/file1.vim') 8253< ~/.c/n/a/file1.vim ~ 8254>vim 8255echo pathshorten('~/.config/nvim/autoload/file2.vim', 2) 8256< ~/.co/nv/au/file2.vim ~ 8257It doesn't matter if the path exists or not. 8258Returns an empty string on error. 8259 8260]=] , 8261name ='pathshorten' , 8262params ={ { 'path' , 'string' } , { 'len' , 'integer' } } , 8263returns ='string' , 8264signature ='pathshorten({path} [, {len}])' , 8265} , 8266perleval ={ 8267args =1 , 8268base =1 , 8269desc =[=[ 8270Evaluate |perl| expression {expr} and return its result 8271converted to Vim data structures. 8272Numbers and strings are returned as they are (strings are 8273copied though). 8274Lists are represented as Vim |List| type. 8275Dictionaries are represented as Vim |Dictionary| type, 8276non-string keys result in error. 8277 8278Note: If you want an array or hash, {expr} must return a 8279reference to it. 8280Example: >vim 8281echo perleval('[1 .. 4]') 8282< [1, 2, 3, 4] 8283 8284]=] , 8285name ='perleval' , 8286params ={ { 'expr' , 'any' } } , 8287signature ='perleval({expr})' , 8288} , 8289pow ={ 8290args =2 , 8291base =1 , 8292desc =[=[ 8293Return the power of {x} to the exponent {y} as a |Float|. 8294{x} and {y} must evaluate to a |Float| or a |Number|. 8295Returns 0.0 if {x} or {y} is not a |Float| or a |Number|. 8296Examples: >vim 8297echo pow(3, 3) 8298< 27.0 >vim 8299echo pow(2, 16) 8300< 65536.0 >vim 8301echo pow(32, 0.20) 8302< 2.0 8303 8304]=] , 8305name ='pow' , 8306params ={ { 'x' , 'number' } , { 'y' , 'number' } } , 8307returns ='number' , 8308signature ='pow({x}, {y})' , 8309see_lua ={ '|math.pow()|' } , 8310} , 8311preinserted ={ 8312desc =[=[ 8313Returns non-zero if text has been inserted after the cursor 8314because "preinsert" is present in 'completeopt', or because 8315"longest" is present in 'completeopt' while 'autocomplete' 8316is active. Otherwise returns zero. 8317]=] , 8318name ='preinserted' , 8319params ={} , 8320returns ='number' , 8321signature ='preinserted()' , 8322} , 8323prevnonblank ={ 8324args =1 , 8325base =1 , 8326desc =[=[ 8327Return the line number of the first line at or above {lnum} 8328that is not blank. Example: >vim 8329let ind = indent(prevnonblank(v:lnum - 1)) 8330<When {lnum} is invalid or there is no non-blank line at or 8331above it, zero is returned. 8332{lnum} is used like with |getline()|. 8333Also see |nextnonblank()|. 8334 8335]=] , 8336name ='prevnonblank' , 8337params ={ { 'lnum' , 'integer|string' } } , 8338returns ='integer' , 8339signature ='prevnonblank({lnum})' , 8340} , 8341printf ={ 8342args ={ 1 } , 8343base =2 , 8344desc =[=[ 8345Return a String with {fmt}, where "%" items are replaced by 8346the formatted form of their respective arguments. Example: >vim 8347echo printf("%4d: E%d %.30s", lnum, errno, msg) 8348<May result in: 8349" 99: E42 asdfasdfasdfasdfasdfasdfasdfas" ~ 8350 8351When used as a |method| the base is passed as the second 8352argument: >vim 8353Compute()->printf("result: %d") 8354< 8355You can use `call()` to pass the items as a list. 8356 8357Often used items are: 8358%s string 8359%6S string right-aligned in 6 display cells 8360%6s string right-aligned in 6 bytes 8361%.9s string truncated to 9 bytes 8362%c single byte 8363%d decimal number 8364%5d decimal number padded with spaces to 5 characters 8365%b binary number 8366%08b binary number padded with zeros to at least 8 characters 8367%B binary number using upper case letters 8368%x hex number 8369%04x hex number padded with zeros to at least 4 characters 8370%X hex number using upper case letters 8371%o octal number 8372%f floating point number as 12.23, inf, -inf or nan 8373%F floating point number as 12.23, INF, -INF or NAN 8374%e floating point number as 1.23e3, inf, -inf or nan 8375%E floating point number as 1.23E3, INF, -INF or NAN 8376%g floating point number, as %f or %e depending on value 8377%G floating point number, as %F or %E depending on value 8378%% the % character itself 8379%p representation of the pointer to the container 8380 8381Conversion specifications start with '%' and end with the 8382conversion type. All other characters are copied unchanged to 8383the result. 8384 8385The "%" starts a conversion specification. The following 8386arguments appear in sequence: 8387 8388% [pos-argument] [flags] [field-width] [.precision] type 8389 8390pos-argument 8391At most one positional argument specifier. These take 8392the form {n$}, where n is >= 1. 8393 8394flags 8395Zero or more of the following flags: 8396 8397# The value should be converted to an "alternate 8398form". For c, d, and s conversions, this option 8399has no effect. For o conversions, the precision 8400of the number is increased to force the first 8401character of the output string to a zero (except 8402if a zero value is printed with an explicit 8403precision of zero). 8404For x and X conversions, a non-zero result has 8405the string "0x" (or "0X" for X conversions) 8406prepended to it. 8407 84080 (zero) Zero padding. For all conversions the converted 8409value is padded on the left with zeros rather 8410than blanks. If a precision is given with a 8411numeric conversion (d, o, x, and X), the 0 flag 8412is ignored. 8413 8414- A negative field width flag; the converted value 8415is to be left adjusted on the field boundary. 8416The converted value is padded on the right with 8417blanks, rather than on the left with blanks or 8418zeros. A - overrides a 0 if both are given. 8419 8420' ' (space) A blank should be left before a positive 8421number produced by a signed conversion (d). 8422 8423+ A sign must always be placed before a number 8424produced by a signed conversion. A + overrides 8425a space if both are used. 8426 8427field-width 8428An optional decimal digit string specifying a minimum 8429field width. If the converted value has fewer bytes 8430than the field width, it will be padded with spaces on 8431the left (or right, if the left-adjustment flag has 8432been given) to fill out the field width. For the S 8433conversion the count is in cells. 8434 8435.precision 8436An optional precision, in the form of a period '.' 8437followed by an optional digit string. If the digit 8438string is omitted, the precision is taken as zero. 8439This gives the minimum number of digits to appear for 8440d, o, x, and X conversions, the maximum number of 8441bytes to be printed from a string for s conversions, 8442or the maximum number of cells to be printed from a 8443string for S conversions. 8444For floating point it is the number of digits after 8445the decimal point. 8446 8447type 8448A character that specifies the type of conversion to 8449be applied, see below. 8450 8451A field width or precision, or both, may be indicated by an 8452asterisk "*" instead of a digit string. In this case, a 8453Number argument supplies the field width or precision. A 8454negative field width is treated as a left adjustment flag 8455followed by a positive field width; a negative precision is 8456treated as though it were missing. Example: >vim 8457echo printf("%d: %.*s", nr, width, line) 8458<This limits the length of the text used from "line" to 8459"width" bytes. 8460 8461If the argument to be formatted is specified using a 8462positional argument specifier, and a '*' is used to indicate 8463that a number argument is to be used to specify the width or 8464precision, the argument(s) to be used must also be specified 8465using a {n$} positional argument specifier. See |printf-$|. 8466 8467The conversion specifiers and their meanings are: 8468 8469*printf-d* *printf-b* *printf-B* *printf-o* *printf-x* *printf-X* 8470dbBoxX The Number argument is converted to signed decimal (d), 8471unsigned binary (b and B), unsigned octal (o), or 8472unsigned hexadecimal (x and X) notation. The letters 8473"abcdef" are used for x conversions; the letters 8474"ABCDEF" are used for X conversions. The precision, if 8475any, gives the minimum number of digits that must 8476appear; if the converted value requires fewer digits, it 8477is padded on the left with zeros. In no case does a 8478non-existent or small field width cause truncation of a 8479numeric field; if the result of a conversion is wider 8480than the field width, the field is expanded to contain 8481the conversion result. 8482The 'h' modifier indicates the argument is 16 bits. 8483The 'l' modifier indicates the argument is a long 8484integer. The size will be 32 bits or 64 bits 8485depending on your platform. 8486The "ll" modifier indicates the argument is 64 bits. 8487The b and B conversion specifiers never take a width 8488modifier and always assume their argument is a 64 bit 8489integer. 8490Generally, these modifiers are not useful. They are 8491ignored when type is known from the argument. 8492 8493i alias for d 8494D alias for ld 8495U alias for lu 8496O alias for lo 8497 8498*printf-c* 8499c The Number argument is converted to a byte, and the 8500resulting character is written. 8501 8502*printf-s* 8503s The text of the String argument is used. If a 8504precision is specified, no more bytes than the number 8505specified are used. 8506If the argument is not a String type, it is 8507automatically converted to text with the same format 8508as ":echo". 8509*printf-S* 8510S The text of the String argument is used. If a 8511precision is specified, no more display cells than the 8512number specified are used. 8513 8514*printf-f* *E807* 8515f F The Float argument is converted into a string of the 8516form 123.456. The precision specifies the number of 8517digits after the decimal point. When the precision is 8518zero the decimal point is omitted. When the precision 8519is not specified 6 is used. A really big number 8520(out of range or dividing by zero) results in "inf" 8521or "-inf" with %f (INF or -INF with %F). 8522"0.0 / 0.0" results in "nan" with %f (NAN with %F). 8523Example: >vim 8524echo printf("%.2f", 12.115) 8525< 12.12 8526Note that roundoff depends on the system libraries. 8527Use |round()| when in doubt. 8528 8529*printf-e* *printf-E* 8530e E The Float argument is converted into a string of the 8531form 1.234e+03 or 1.234E+03 when using 'E'. The 8532precision specifies the number of digits after the 8533decimal point, like with 'f'. 8534 8535*printf-g* *printf-G* 8536g G The Float argument is converted like with 'f' if the 8537value is between 0.001 (inclusive) and 10000000.0 8538(exclusive). Otherwise 'e' is used for 'g' and 'E' 8539for 'G'. When no precision is specified superfluous 8540zeroes and '+' signs are removed, except for the zero 8541immediately after the decimal point. Thus 10000000.0 8542results in 1.0e7. 8543 8544*printf-%* 8545% A '%' is written. No argument is converted. The 8546complete conversion specification is "%%". 8547 8548When a Number argument is expected a String argument is also 8549accepted and automatically converted. 8550When a Float or String argument is expected a Number argument 8551is also accepted and automatically converted. 8552Any other argument type results in an error message. 8553 8554*E766* *E767* 8555The number of {exprN} arguments must exactly match the number 8556of "%" items. If there are not sufficient or too many 8557arguments an error is given. Up to 18 arguments can be used. 8558 8559*printf-$* 8560In certain languages, error and informative messages are 8561more readable when the order of words is different from the 8562corresponding message in English. To accommodate translations 8563having a different word order, positional arguments may be 8564used to indicate this. For instance: >vim 8565 8566#, c-format 8567msgid "%s returning %s" 8568msgstr "waarde %2$s komt terug van %1$s" 8569< 8570In this example, the sentence has its 2 string arguments 8571reversed in the output. >vim 8572 8573echo printf( 8574"In The Netherlands, vim's creator's name is: %1$s %2$s", 8575"Bram", "Moolenaar") 8576< In The Netherlands, vim's creator's name is: Bram Moolenaar >vim 8577 8578echo printf( 8579"In Belgium, vim's creator's name is: %2$s %1$s", 8580"Bram", "Moolenaar") 8581< In Belgium, vim's creator's name is: Moolenaar Bram 8582 8583Width (and precision) can be specified using the '*' 8584specifier. In this case, you must specify the field width 8585position in the argument list. >vim 8586 8587echo printf("%1$*2$.*3$d", 1, 2, 3) 8588< 001 >vim 8589echo printf("%2$*3$.*1$d", 1, 2, 3) 8590< 2 >vim 8591echo printf("%3$*1$.*2$d", 1, 2, 3) 8592< 03 >vim 8593echo printf("%1$*2$.*3$g", 1.4142, 2, 3) 8594< 1.414 8595 8596You can mix specifying the width and/or precision directly 8597and via positional arguments: >vim 8598 8599echo printf("%1$4.*2$f", 1.4142135, 6) 8600< 1.414214 >vim 8601echo printf("%1$*2$.4f", 1.4142135, 6) 8602< 1.4142 >vim 8603echo printf("%1$*2$.*3$f", 1.4142135, 6, 2) 8604< 1.41 8605 8606You will get an overflow error |E1510|, when the field-width 8607or precision will result in a string longer than 1 MiB 8608(1024*1024 = 1048576) chars. 8609 8610*E1500* 8611You cannot mix positional and non-positional arguments: >vim 8612echo printf("%s%1$s", "One", "Two") 8613" E1500: Cannot mix positional and non-positional arguments: 8614" %s%1$s 8615< 8616*E1501* 8617You cannot skip a positional argument in a format string: >vim 8618echo printf("%3$s%1$s", "One", "Two", "Three") 8619" E1501: format argument 2 unused in $-style format: 8620" %3$s%1$s 8621< 8622*E1502* 8623You can re-use a [field-width] (or [precision]) argument: >vim 8624echo printf("%1$d at width %2$d is: %1$0*2$d", 1, 2) 8625" 1 at width 2 is: 01 8626< 8627However, you can't use it as a different type: >vim 8628echo printf("%1$d at width %2$ld is: %1$0*2$d", 1, 2) 8629" E1502: Positional argument 2 used as field width reused as 8630" different type: long int/int 8631< 8632*E1503* 8633When a positional argument is used, but not the correct number 8634or arguments is given, an error is raised: >vim 8635echo printf("%1$d at width %2$d is: %1$0*2$.*3$d", 1, 2) 8636" E1503: Positional argument 3 out of bounds: %1$d at width 8637" %2$d is: %1$0*2$.*3$d 8638< 8639Only the first error is reported: >vim 8640echo printf("%1$0*2$.*3$d %4$d", 1, 2) 8641" E1503: Positional argument 3 out of bounds: %1$0*2$.*3$d 8642" %4$d 8643< 8644*E1504* 8645A positional argument can be used more than once: >vim 8646echo printf("%1$s %2$s %1$s", "One", "Two") 8647" One Two One 8648< 8649However, you can't use a different type the second time: >vim 8650echo printf("%1$s %2$s %1$d", "One", "Two") 8651" E1504: Positional argument 1 type used inconsistently: 8652" int/string 8653< 8654*E1505* 8655Various other errors that lead to a format string being 8656wrongly formatted lead to: >vim 8657echo printf("%1$d at width %2$d is: %01$*2$.3$d", 1, 2) 8658" E1505: Invalid format specifier: %1$d at width %2$d is: 8659" %01$*2$.3$d 8660< 8661*E1507* 8662This internal error indicates that the logic to parse a 8663positional format argument ran into a problem that couldn't be 8664otherwise reported. Please file a bug against Vim if you run 8665into this, copying the exact format string and parameters that 8666were used. 8667 8668]=] , 8669name ='printf' , 8670params ={ { 'fmt' , 'string' } , { 'expr1' , 'any' } } , 8671signature ='printf({fmt}, {expr1} ...)' , 8672returns ='string' , 8673see_lua ={ '|string.format()|' } , 8674} , 8675prompt_appendbuf ={ 8676args =2 , 8677base =2 , 8678desc =[=[ 8679Appends text to prompt buffer before current prompt. When {text} is 8680a |List|: Append each item of the |List| as a text line above 8681prompt-line in the buffer. Any type of item is accepted and converted 8682to a String. Returns 1 for failure ({buf} not a prmopt buffer), 86830 for success. When {text} is an empty list zero is returned. 8684 8685Example: >vim 8686func TextEntered(text) 8687call prompt_appendbuf(bufnr(''), split('Entered: "' . a:text . '"', '\n')) 8688endfunc 8689 8690set buftype=prompt 8691call prompt_setcallback(bufnr(''), function("TextEntered")) 8692eval bufnr("")->prompt_setprompt("cmd: ") 8693startinsert 8694< 8695]=] , 8696name ='prompt_appendbuf' , 8697params ={ { 'buf' , 'integer|string' } , { 'text' , 'string|string[]' } } , 8698returns ='0|1' , 8699signature ='prompt_appendbuf({buf}, {text})' , 8700} , 8701prompt_getinput ={ 8702args =1 , 8703base =1 , 8704desc =[=[ 8705Gets the current user-input in |prompt-buffer| {buf} without invoking 8706prompt_callback. {buf} can be a buffer name or number. 8707 8708If the buffer doesn't exist or isn't a prompt buffer, an empty 8709string is returned. 8710 8711]=] , 8712name ='prompt_getinput' , 8713params ={ { 'buf' , 'integer|string' } } , 8714signature ='prompt_getinput({buf})' , 8715} , 8716prompt_getprompt ={ 8717args =1 , 8718base =1 , 8719desc =[=[ 8720Returns the effective prompt text for buffer {buf}. {buf} can 8721be a buffer name or number. See |prompt-buffer|. 8722 8723If the buffer doesn't exist or isn't a prompt buffer, an empty 8724string is returned. 8725 8726]=] , 8727name ='prompt_getprompt' , 8728params ={ { 'buf' , 'integer|string' } } , 8729signature ='prompt_getprompt({buf})' , 8730} , 8731prompt_setcallback ={ 8732args ={ 2 , 2 } , 8733base =1 , 8734desc =[=[ 8735Set prompt callback for buffer {buf} to {expr}. When {expr} 8736is an empty string the callback is removed. This has only 8737effect if {buf} has 'buftype' set to "prompt". 8738 8739The callback is invoked when pressing Enter. The current 8740buffer will always be the prompt buffer. A new line for a 8741prompt is added before invoking the callback, thus the prompt 8742for which the callback was invoked will be in the last but one 8743line. 8744If the callback wants to add text to the buffer, it must 8745insert it above the last line, since that is where the current 8746prompt is. This can also be done asynchronously. 8747The callback is invoked with one argument, which is the text 8748that was entered at the prompt. This can be an empty string 8749if the user only typed Enter. 8750Example: >vim 8751func s:TextEntered(text) 8752if a:text == 'exit' || a:text == 'quit' 8753stopinsert 8754" Reset 'modified' to allow the buffer to be closed. 8755" We assume there is nothing useful to be saved. 8756set nomodified 8757close 8758else 8759" Do something useful with "a:text". In this example 8760" we just repeat it. 8761call append(line('$') - 1, 'Entered: "' .. a:text .. '"') 8762endif 8763endfunc 8764call prompt_setcallback(bufnr(), function('s:TextEntered')) 8765< 8766]=] , 8767name ='prompt_setcallback' , 8768params ={ { 'buf' , 'integer|string' } , { 'expr' , 'string|function' } } , 8769signature ='prompt_setcallback({buf}, {expr})' , 8770} , 8771prompt_setinterrupt ={ 8772args ={ 2 , 2 } , 8773base =1 , 8774desc =[=[ 8775Set a callback for buffer {buf} to {expr}. When {expr} is an 8776empty string the callback is removed. This has only effect if 8777{buf} has 'buftype' set to "prompt". 8778 8779This callback will be invoked when pressing CTRL-C in Insert 8780mode. Without setting a callback Vim will exit Insert mode, 8781as in any buffer. 8782 8783]=] , 8784name ='prompt_setinterrupt' , 8785params ={ { 'buf' , 'integer|string' } , { 'expr' , 'string|function' } } , 8786signature ='prompt_setinterrupt({buf}, {expr})' , 8787} , 8788prompt_setprompt ={ 8789args ={ 2 , 2 } , 8790base =1 , 8791desc =[=[ 8792Set prompt for buffer {buf} to {text}. You most likely want 8793{text} to end in a space. 8794The result is only visible if {buf} has 'buftype' set to 8795"prompt". Example: >vim 8796call prompt_setprompt(bufnr(''), 'command: ') 8797< 8798]=] , 8799name ='prompt_setprompt' , 8800params ={ { 'buf' , 'integer|string' } , { 'text' , 'string' } } , 8801signature ='prompt_setprompt({buf}, {text})' , 8802} , 8803pum_getpos ={ 8804desc =[=[ 8805If the popup menu (see |ins-completion-menu|) is not visible, 8806returns an empty |Dictionary|, otherwise, returns a 8807|Dictionary| with the following keys: 8808height nr of items visible 8809width screen cells 8810row top screen row (0 first row) 8811col leftmost screen column (0 first col) 8812size total nr of items 8813scrollbar |TRUE| if scrollbar is visible 8814 8815The values are the same as in |v:event| during |CompleteChanged|. 8816]=] , 8817name ='pum_getpos' , 8818params ={} , 8819signature ='pum_getpos()' , 8820} , 8821pumvisible ={ 8822desc =[=[ 8823Returns non-zero when the popup menu is visible, zero 8824otherwise. See |ins-completion-menu|. 8825This can be used to avoid some things that would remove the 8826popup menu. 8827]=] , 8828name ='pumvisible' , 8829params ={} , 8830signature ='pumvisible()' , 8831} , 8832py3eval ={ 8833args =1 , 8834base =1 , 8835desc =[=[ 8836Evaluate Python expression {expr} and return its result 8837converted to Vim data structures. 8838Numbers and strings are returned as they are (strings are 8839copied though, Unicode strings are additionally converted to 8840UTF-8). 8841Lists are represented as Vim |List| type. 8842Dictionaries are represented as Vim |Dictionary| type with 8843keys converted to strings. 8844 8845]=] , 8846name ='py3eval' , 8847params ={ { 'expr' , 'any' } } , 8848signature ='py3eval({expr})' , 8849} , 8850pyeval ={ 8851args =1 , 8852base =1 , 8853desc =[=[ 8854Evaluate Python expression {expr} and return its result 8855converted to Vim data structures. 8856Numbers and strings are returned as they are (strings are 8857copied though). 8858Lists are represented as Vim |List| type. 8859Dictionaries are represented as Vim |Dictionary| type, 8860non-string keys result in error. 8861 8862]=] , 8863func ='f_py3eval' , 8864name ='pyeval' , 8865params ={ { 'expr' , 'any' } } , 8866signature ='pyeval({expr})' , 8867tags ={ 'E858' , 'E859' } , 8868} , 8869pyxeval ={ 8870args =1 , 8871base =1 , 8872desc =[=[ 8873Evaluate Python expression {expr} and return its result 8874converted to Vim data structures. 8875Uses Python 2 or 3, see |python_x| and 'pyxversion'. 8876See also: |pyeval()|, |py3eval()| 8877 8878]=] , 8879func ='f_py3eval' , 8880name ='pyxeval' , 8881params ={ { 'expr' , 'any' } } , 8882signature ='pyxeval({expr})' , 8883} , 8884rand ={ 8885args ={ 0 , 1 } , 8886base =1 , 8887desc =[=[ 8888Return a pseudo-random Number generated with an xoshiro128** 8889algorithm using seed {expr}. The returned number is 32 bits, 8890also on 64 bits systems, for consistency. 8891{expr} can be initialized by |srand()| and will be updated by 8892rand(). If {expr} is omitted, an internal seed value is used 8893and updated. 8894Returns -1 if {expr} is invalid. 8895 8896Examples: >vim 8897echo rand() 8898let seed = srand() 8899echo rand(seed) 8900echo rand(seed) % 16 " random number 0 - 15 8901< 8902]=] , 8903name ='rand' , 8904params ={ { 'expr' , 'number' } } , 8905signature ='rand([{expr}])' , 8906see_lua ={ '|math.random()|' } , 8907} , 8908range ={ 8909args ={ 1 , 3 } , 8910base =1 , 8911desc =[=[ 8912Returns a |List| with Numbers: 8913- If only {expr} is specified: [0, 1, ..., {expr} - 1] 8914- If {max} is specified: [{expr}, {expr} + 1, ..., {max}] 8915- If {stride} is specified: [{expr}, {expr} + {stride}, ..., 8916{max}] (increasing {expr} with {stride} each time, not 8917producing a value past {max}). 8918When the maximum is one before the start the result is an 8919empty list. When the maximum is more than one before the 8920start this is an error. 8921Examples: >vim 8922echo range(4) " [0, 1, 2, 3] 8923echo range(2, 4) " [2, 3, 4] 8924echo range(2, 9, 3) " [2, 5, 8] 8925echo range(2, -2, -1) " [2, 1, 0, -1, -2] 8926echo range(0) " [] 8927echo range(2, 0) " error! 8928< 8929]=] , 8930name ='range' , 8931params ={ { 'expr' , 'any' } , { 'max' , 'integer' } , { 'stride' , 'integer' } } , 8932signature ='range({expr} [, {max} [, {stride}]])' , 8933tags ={ 'E726' , 'E727' } , 8934} , 8935readblob ={ 8936args ={ 1 , 3 } , 8937base =1 , 8938desc =[=[ 8939Read file {fname} in binary mode and return a |Blob|. 8940If {offset} is specified, read the file from the specified 8941offset. If it is a negative value, it is used as an offset 8942from the end of the file. E.g., to read the last 12 bytes: >vim 8943echo readblob('file.bin', -12) 8944<If {size} is specified, only the specified size will be read. 8945E.g. to read the first 100 bytes of a file: >vim 8946echo readblob('file.bin', 0, 100) 8947<If {size} is -1 or omitted, the whole data starting from 8948{offset} will be read. 8949This can be also used to read the data from a character device 8950on Unix when {size} is explicitly set. Only if the device 8951supports seeking {offset} can be used. Otherwise it should be 8952zero. E.g. to read 10 bytes from a serial console: >vim 8953echo readblob('/dev/ttyS0', 0, 10) 8954<When the file can't be opened an error message is given and 8955the result is an empty |Blob|. 8956When the offset is beyond the end of the file the result is an 8957empty blob. 8958When trying to read more bytes than are available the result 8959is truncated. 8960Also see |readfile()| and |writefile()|. 8961]=] , 8962name ='readblob' , 8963params ={ { 'fname' , 'string' } , { 'offset' , 'integer' } , { 'size' , 'integer' } } , 8964signature ='readblob({fname} [, {offset} [, {size}]])' , 8965see_lua ={ 8966'|io.open()| with `:read("*a")` in binary mode for whole-file reads; offset, size, and Blob return differ' , 8967} , 8968} , 8969readdir ={ 8970args ={ 1 , 2 } , 8971base =1 , 8972desc =[=[ 8973Return a list with file and directory names in {directory}. 8974You can also use |glob()| if you don't need to do complicated 8975things, such as limiting the number of matches. 8976 8977When {expr} is omitted all entries are included. 8978When {expr} is given, it is evaluated to check what to do: 8979If {expr} results in -1 then no further entries will 8980be handled. 8981If {expr} results in 0 then this entry will not be 8982added to the list. 8983If {expr} results in 1 then this entry will be added 8984to the list. 8985Each time {expr} is evaluated |v:val| is set to the entry name. 8986When {expr} is a function the name is passed as the argument. 8987For example, to get a list of files ending in ".txt": >vim 8988echo readdir(dirname, {n -> n =~ '\.txt$'}) 8989<To skip hidden and backup files: >vim 8990echo readdir(dirname, {n -> n !~ '^\.\|\~$'}) 8991 8992<If you want to get a directory tree: >vim 8993function! s:tree(dir) 8994return {a:dir : map(readdir(a:dir), 8995\ {_, x -> isdirectory(x) ? 8996\ {x : s:tree(a:dir .. '/' .. x)} : x})} 8997endfunction 8998echo s:tree(".") 8999< 9000Returns an empty List on error. 9001 9002]=] , 9003name ='readdir' , 9004params ={ { 'directory' , 'string' } , { 'expr' , 'integer|string|fun(name: string): integer' } } , 9005signature ='readdir({directory} [, {expr}])' , 9006see_lua ={ '|vim.fs.dir()| as an iterator, then collect and filter results as needed' } , 9007} , 9008readfile ={ 9009args ={ 1 , 3 } , 9010base =1 , 9011desc =[=[ 9012Read file {fname} and return a |List|, each line of the file 9013as an item. Lines are broken at NL characters. Macintosh 9014files separated with CR will result in a single long line 9015(unless a NL appears somewhere). 9016All NUL characters are replaced with a NL character. 9017When {type} contains "b" binary mode is used: 9018- When the last line ends in a NL an extra empty list item is 9019added. 9020- No CR characters are removed. 9021Otherwise: 9022- CR characters that appear before a NL are removed. 9023- Whether the last line ends in a NL or not does not matter. 9024- Any UTF-8 byte order mark is removed from the text. 9025When {max} is given this specifies the maximum number of lines 9026to be read. Useful if you only want to check the first ten 9027lines of a file: >vim 9028for line in readfile(fname, '', 10) 9029if line =~ 'Date' | echo line | endif 9030endfor 9031<When {max} is negative -{max} lines from the end of the file 9032are returned, or as many as there are. 9033When {max} is zero the result is an empty list. 9034Note that without {max} the whole file is read into memory. 9035Also note that there is no recognition of encoding. Read a 9036file into a buffer if you need to. 9037Deprecated (use |readblob()| instead): When {type} contains 9038"B" a |Blob| is returned with the binary data of the file 9039unmodified. 9040When the file can't be opened an error message is given and 9041the result is an empty list. 9042Also see |writefile()|. 9043 9044]=] , 9045name ='readfile' , 9046params ={ { 'fname' , 'string' } , { 'type' , 'string' } , { 'max' , 'integer' } } , 9047returns ='string[]' , 9048signature ='readfile({fname} [, {type} [, {max}]])' , 9049see_lua ={ 9050'|io.open()| with `:read("*a")`, then split lines as needed; `{type}`, `{max}`, and Blob return differ' , 9051} , 9052} , 9053reduce ={ 9054args ={ 2 , 3 } , 9055base =1 , 9056tags ={ 'E998' } , 9057desc =[=[ 9058{func} is called for every item in {object}, which can be a 9059|String|, |List| or a |Blob|. {func} is called with two 9060arguments: the result so far and current item. After 9061processing all items the result is returned. *E1132* 9062 9063{initial} is the initial result. When omitted, the first item 9064in {object} is used and {func} is first called for the second 9065item. If {initial} is not given and {object} is empty no 9066result can be computed, an E998 error is given. 9067 9068Examples: >vim 9069echo reduce([1, 3, 5], { acc, val -> acc + val }) 9070echo reduce(['x', 'y'], { acc, val -> acc .. val }, 'a') 9071echo reduce(0z1122, { acc, val -> 2 * acc + val }) 9072echo reduce('xyz', { acc, val -> acc .. ',' .. val }) 9073< 9074]=] , 9075name ='reduce' , 9076generics ={ 'T' } , 9077params ={ 9078{ 'object' , 'any' } , 9079{ 'func' , 'fun(accumulator: T, current: any): any' } , 9080{ 'initial' , 'any' } , 9081} , 9082returns ='T' , 9083signature ='reduce({object}, {func} [, {initial}])' , 9084see_lua ={ '|Iter:fold()|' } , 9085} , 9086reg_executing ={ 9087desc =[=[ 9088Returns the single letter name of the register being executed. 9089Returns an empty string when no register is being executed. 9090See |@|. 9091]=] , 9092name ='reg_executing' , 9093params ={} , 9094signature ='reg_executing()' , 9095} , 9096reg_recorded ={ 9097desc =[=[ 9098Returns the single letter name of the last recorded register. 9099Returns an empty string when nothing was recorded yet. 9100See |q| and |Q|. 9101]=] , 9102name ='reg_recorded' , 9103params ={} , 9104signature ='reg_recorded()' , 9105} , 9106reg_recording ={ 9107desc =[=[ 9108Returns the single letter name of the register being recorded. 9109Returns an empty string when not recording. See |q|. 9110]=] , 9111name ='reg_recording' , 9112params ={} , 9113signature ='reg_recording()' , 9114} , 9115reltime ={ 9116args ={ 0 , 2 } , 9117base =1 , 9118fast =true , 9119name ='reltime' , 9120params ={} , 9121signature ='reltime()' , 9122} , 9123reltime__1 ={ 9124args ={ 0 , 2 } , 9125base =1 , 9126fast =true , 9127name ='reltime' , 9128params ={ { 'start' , 'any' } } , 9129signature ='reltime({start})' , 9130} , 9131reltime__2 ={ 9132args ={ 0 , 2 } , 9133base =1 , 9134desc =[=[ 9135Return an item that represents a time value. The item is a 9136list with items that depend on the system. 9137The item can be passed to |reltimestr()| to convert it to a 9138string or |reltimefloat()| to convert to a Float. 9139 9140Without an argument it returns the current "relative time", an 9141implementation-defined value meaningful only when used as an 9142argument to |reltime()|, |reltimestr()| and |reltimefloat()|. 9143 9144With one argument it returns the time passed since the time 9145specified in the argument. 9146With two arguments it returns the time passed between {start} 9147and {end}. 9148 9149The {start} and {end} arguments must be values returned by 9150reltime(). Returns zero on error. 9151 9152Note: |localtime()| returns the current (non-relative) time. 9153]=] , 9154fast =true , 9155name ='reltime' , 9156params ={ { 'start' , 'any' } , { 'end' , 'any' } } , 9157signature ='reltime({start}, {end})' , 9158see_lua ={ '|uv.hrtime()|' } , 9159} , 9160reltimefloat ={ 9161args =1 , 9162base =1 , 9163desc =[=[ 9164Return a Float that represents the time value of {time}. 9165Unit of time is seconds. 9166Example: 9167let start = reltime() 9168call MyFunction() 9169let seconds = reltimefloat(reltime(start)) 9170See the note of |reltimestr()| about overhead. 9171Also see |profiling|. 9172If there is an error an empty string is returned 9173 9174]=] , 9175fast =true , 9176name ='reltimefloat' , 9177params ={ { 'time' , 'any' } } , 9178signature ='reltimefloat({time})' , 9179see_lua ={ '|uv.hrtime()| with `(finish - start) / 1e9` for elapsed seconds' } , 9180} , 9181reltimestr ={ 9182args =1 , 9183base =1 , 9184desc =[=[ 9185Return a String that represents the time value of {time}. 9186This is the number of seconds, a dot and the number of 9187microseconds. Example: >vim 9188let start = reltime() 9189call MyFunction() 9190echo reltimestr(reltime(start)) 9191<Note that overhead for the commands will be added to the time. 9192Leading spaces are used to make the string align nicely. You 9193can use |split()| to remove it. >vim 9194echo split(reltimestr(reltime(start)))[0] 9195<Also see |profiling|. 9196If there is an error an empty string is returned 9197 9198]=] , 9199fast =true , 9200name ='reltimestr' , 9201params ={ { 'time' , 'any' } } , 9202signature ='reltimestr({time})' , 9203} , 9204remove ={ 9205args ={ 2 , 3 } , 9206base =1 , 9207name ='remove' , 9208params ={ { 'list' , 'any' } , { 'idx' , 'integer' } } , 9209signature ='remove({list}, {idx})' , 9210see_lua ={ '|table.remove()|' } , 9211} , 9212remove__1 ={ 9213args ={ 2 , 3 } , 9214base =1 , 9215desc =[=[ 9216Without {end}: Remove the item at {idx} from |List| {list} and 9217return the item. 9218With {end}: Remove items from {idx} to {end} (inclusive) and 9219return a |List| with these items. When {idx} points to the same 9220item as {end} a list with one item is returned. When {end} 9221points to an item before {idx} this is an error. 9222See |list-index| for possible values of {idx} and {end}. 9223Returns zero on error. 9224Example: >vim 9225echo "last item: " .. remove(mylist, -1) 9226call remove(mylist, 0, 9) 9227< 9228Use |delete()| to remove a file. 9229 9230]=] , 9231name ='remove' , 9232params ={ { 'list' , 'any[]' } , { 'idx' , 'integer' } , { 'end' , 'integer' } } , 9233signature ='remove({list}, {idx}, {end})' , 9234} , 9235remove__2 ={ 9236args ={ 2 , 3 } , 9237base =1 , 9238name ='remove' , 9239params ={ { 'blob' , 'any' } , { 'idx' , 'integer' } } , 9240signature ='remove({blob}, {idx})' , 9241} , 9242remove__3 ={ 9243args ={ 2 , 3 } , 9244base =1 , 9245desc =[=[ 9246Without {end}: Remove the byte at {idx} from |Blob| {blob} and 9247return the byte. 9248With {end}: Remove bytes from {idx} to {end} (inclusive) and 9249return a |Blob| with these bytes. When {idx} points to the same 9250byte as {end} a |Blob| with one byte is returned. When {end} 9251points to a byte before {idx} this is an error. 9252Returns zero on error. 9253Example: >vim 9254echo "last byte: " .. remove(myblob, -1) 9255call remove(mylist, 0, 9) 9256< 9257]=] , 9258name ='remove' , 9259params ={ { 'blob' , 'any' } , { 'idx' , 'integer' } , { 'end' , 'integer' } } , 9260signature ='remove({blob}, {idx}, {end})' , 9261} , 9262remove__4 ={ 9263args ={ 2 , 3 } , 9264base =1 , 9265desc =[=[ 9266Remove the entry from {dict} with key {key} and return it. 9267Example: >vim 9268echo "removed " .. remove(dict, "one") 9269<If there is no {key} in {dict} this is an error. 9270Returns zero on error. 9271]=] , 9272name ='remove' , 9273params ={ { 'dict' , 'any' } , { 'key' , 'string' } } , 9274signature ='remove({dict}, {key})' , 9275see_lua ={ 9276'`local value = dict[key]; dict[key] = nil` for dicts; missing-key behavior differs' , 9277} , 9278} , 9279rename ={ 9280args =2 , 9281base =1 , 9282desc =[=[ 9283Rename the file by the name {from} to the name {to}. This 9284should also work to move files across file systems. The 9285result is a Number, which is 0 if the file was renamed 9286successfully, and non-zero when the renaming failed. 9287NOTE: If {to} exists it is overwritten without warning. 9288This function is not available in the |sandbox|. 9289 9290]=] , 9291name ='rename' , 9292params ={ { 'from' , 'string' } , { 'to' , 'string' } } , 9293returns ='integer' , 9294signature ='rename({from}, {to})' , 9295see_lua ={ '|uv.fs_rename()|' , '|os.rename()|' } , 9296} , 9297[ 'repeat' ] ={ 9298args =2 , 9299base =1 , 9300desc =[=[ 9301Repeat {expr} {count} times and return the concatenated 9302result. Example: >vim 9303let separator = repeat('-', 80) 9304<When {count} is zero or negative the result is empty. 9305When {expr} is a |List| or a |Blob| the result is {expr} 9306concatenated {count} times. Example: >vim 9307let longlist = repeat(['a', 'b'], 3) 9308<Results in ['a', 'b', 'a', 'b', 'a', 'b']. 9309 9310]=] , 9311fast =true , 9312name ='repeat' , 9313params ={ { 'expr' , 'any' } , { 'count' , 'integer' } } , 9314signature ='repeat({expr}, {count})' , 9315see_lua ={ '|string.rep()| for strings; lists need manual repetition' } , 9316} , 9317resolve ={ 9318args =1 , 9319base =1 , 9320tags ={ 'E655' } , 9321desc =[=[ 9322On MS-Windows, when {filename} is a shortcut (a .lnk file), 9323returns the path the shortcut points to in a simplified form. 9324On Unix, repeat resolving symbolic links in all path 9325components of {filename} and return the simplified result. 9326To cope with link cycles, resolving of symbolic links is 9327stopped after 100 iterations. 9328On other systems, return the simplified {filename}. 9329The simplification step is done as by |simplify()|. 9330resolve() keeps a leading path component specifying the 9331current directory (provided the result is still a relative 9332path name) and also keeps a trailing path separator. 9333 9334]=] , 9335fast =true , 9336name ='resolve' , 9337params ={ { 'filename' , 'string' } } , 9338returns ='string' , 9339signature ='resolve({filename})' , 9340} , 9341reverse ={ 9342args =1 , 9343base =1 , 9344desc =[=[ 9345Reverse the order of items in {object}. {object} can be a 9346|List|, a |Blob| or a |String|. For a List and a Blob the 9347items are reversed in-place and {object} is returned. 9348For a String a new String is returned. 9349Returns zero if {object} is not a List, Blob or a String. 9350If you want a List or Blob to remain unmodified make a copy 9351first: >vim 9352let revlist = reverse(copy(mylist)) 9353< 9354]=] , 9355name ='reverse' , 9356generics ={ 'T' } , 9357params ={ { 'object' , 'T[]' } } , 9358returns ='T[]' , 9359signature ='reverse({object})' , 9360see_lua ={ 9361'`vim.iter(list):rev():totable()` for lists; strings, blobs, and in-place behavior differ' , 9362} , 9363} , 9364round ={ 9365args =1 , 9366base =1 , 9367desc =[=[ 9368Round off {expr} to the nearest integral value and return it 9369as a |Float|. If {expr} lies halfway between two integral 9370values, then use the larger one (away from zero). 9371{expr} must evaluate to a |Float| or a |Number|. 9372Returns 0.0 if {expr} is not a |Float| or a |Number|. 9373Examples: >vim 9374echo round(0.456) 9375< 0.0 >vim 9376echo round(4.5) 9377< 5.0 >vim 9378echo round(-4.5) 9379< -5.0 9380 9381]=] , 9382func_float ='round' , 9383name ='round' , 9384params ={ { 'expr' , 'number' } } , 9385returns ='number' , 9386signature ='round({expr})' , 9387see_lua ={ 9388'`expr >= 0 and math.floor(expr + 0.5) or math.ceil(expr - 0.5)` for half-away-from-zero rounding' , 9389} , 9390} , 9391rpcnotify ={ 9392args ={ 2 } , 9393desc =[=[ 9394Sends {event} to {channel} via |RPC| and returns immediately. 9395If {channel} is 0, the event is broadcast to all channels. 9396Example: >vim 9397au VimLeave call rpcnotify(0, "leaving") 9398< 9399]=] , 9400name ='rpcnotify' , 9401params ={ { 'channel' , 'integer' } , { 'event' , 'string' } , { '...' , 'any' } } , 9402returns ='integer' , 9403signature ='rpcnotify({channel}, {event} [, {args}...])' , 9404see_lua ={ '|vim.rpcnotify()|' } , 9405} , 9406rpcrequest ={ 9407args ={ 2 } , 9408desc =[=[ 9409Sends a request to {channel} to invoke {method} via 9410|RPC| and blocks until a response is received. 9411Example: >vim 9412let result = rpcrequest(rpc_chan, "func", 1, 2, 3) 9413< 9414]=] , 9415name ='rpcrequest' , 9416params ={ { 'channel' , 'integer' } , { 'method' , 'string' } , { '...' , 'any' } } , 9417signature ='rpcrequest({channel}, {method} [, {args}...])' , 9418see_lua ={ '|vim.rpcrequest()|' } , 9419} , 9420rpcstart ={ 9421deprecated =true , 9422args ={ 1 , 2 } , 9423desc =[=[ 9424Deprecated. Replace >vim 9425let id = rpcstart('prog', ['arg1', 'arg2']) 9426<with >vim 9427let id = jobstart(['prog', 'arg1', 'arg2'], {'rpc': v:true}) 9428< 9429]=] , 9430name ='rpcstart' , 9431params ={ { 'prog' , 'string' } , { 'argv' , 'any' } } , 9432signature ='rpcstart({prog} [, {argv}])' , 9433} , 9434rpcstop ={ 9435args =1 , 9436deprecated =true , 9437desc =[=[ 9438Use |jobstop()| instead to stop any job, or 9439`chanclose(id, "rpc")` to close RPC communication 9440without stopping the job. Use chanclose(id) to close 9441any socket. 9442]=] , 9443params =VARARGS , 9444signature ='rpcstop(...)' , 9445} , 9446rubyeval ={ 9447args =1 , 9448base =1 , 9449desc =[=[ 9450Evaluate Ruby expression {expr} and return its result 9451converted to Vim data structures. 9452Numbers, floats and strings are returned as they are (strings 9453are copied though). 9454Arrays are represented as Vim |List| type. 9455Hashes are represented as Vim |Dictionary| type. 9456Other objects are represented as strings resulted from their 9457"Object#to_s" method. 9458 9459]=] , 9460name ='rubyeval' , 9461params ={ { 'expr' , 'any' } } , 9462signature ='rubyeval({expr})' , 9463} , 9464screenattr ={ 9465args =2 , 9466base =1 , 9467desc =[=[ 9468Like |screenchar()|, but return the attribute. This is a rather 9469arbitrary number that can only be used to compare to the 9470attribute at other positions. 9471Returns -1 when row or col is out of range. 9472 9473]=] , 9474name ='screenattr' , 9475params ={ { 'row' , 'integer' } , { 'col' , 'integer' } } , 9476returns ='integer' , 9477signature ='screenattr({row}, {col})' , 9478} , 9479screenchar ={ 9480args =2 , 9481base =1 , 9482desc =[=[ 9483Returns the character at screen position [row, col] as a 9484Number. This works for every possible screen position, also 9485status lines, window separators and the command line. The 9486top left position is row one, column one. The character 9487excludes composing characters. For double-byte 9488encodings it may only be the first byte. 9489This is mainly to be used for testing. 9490Returns -1 when row or col is out of range. 9491 9492]=] , 9493name ='screenchar' , 9494params ={ { 'row' , 'integer' } , { 'col' , 'integer' } } , 9495returns ='integer' , 9496signature ='screenchar({row}, {col})' , 9497} , 9498screenchars ={ 9499args =2 , 9500base =1 , 9501desc =[=[ 9502Returns the character and any composing characters at screen 9503position [row, col] as a |List| of Numbers. The first number 9504is the same as what |screenchar()| returns; further numbers 9505are composing characters on top of the base character. 9506This is mainly to be used for testing. 9507Returns an empty List when row or col is out of range. 9508 9509]=] , 9510name ='screenchars' , 9511params ={ { 'row' , 'integer' } , { 'col' , 'integer' } } , 9512returns ='integer[]' , 9513signature ='screenchars({row}, {col})' , 9514} , 9515screencol ={ 9516desc =[=[ 9517Returns the current screen column of the cursor. The 9518leftmost column has number 1. 9519This function is mainly used for testing. 9520 9521Note: Always returns the current screen column, thus if used 9522in a command (e.g. ":echo screencol()") it will return the 9523column inside the command line, which is 1 when the command is 9524executed. To get the cursor position in the file use one of 9525the following mappings: >vim 9526nnoremap <expr> GG ":echom " .. screencol() .. "\n" 9527nnoremap <silent> GG :echom screencol()<CR> 9528noremap GG <Cmd>echom screencol()<CR> 9529< 9530]=] , 9531name ='screencol' , 9532params ={} , 9533returns ='integer' , 9534signature ='screencol()' , 9535} , 9536screenpos ={ 9537args =3 , 9538base =1 , 9539desc =[=[ 9540Returns the screen position of the text character in window 9541{winid} at buffer line {lnum} and column {col} as a Dict. 9542{col} is a one-based byte index. 9543The Dict has these members: 9544row screen row 9545col first screen column 9546endcol last screen column 9547curscol cursor screen column 9548If the specified position is not visible, all values are zero. 9549The "endcol" value differs from "col" when the character 9550occupies more than one screen cell. E.g. for a Tab "col" can 9551be 1 and "endcol" can be 8. 9552The "curscol" value is where the cursor would be placed. For 9553a Tab it would be the same as "endcol", while for a double 9554width character it would be the same as "col". 9555The |conceal| feature is ignored here, the column numbers are 9556as if 'conceallevel' is zero. You can set the cursor to the 9557right position and use |screencol()| to get the value with 9558|conceal| taken into account. 9559If the position is in a closed fold the screen position of the 9560first character is returned, {col} is not used. 9561Returns an empty Dict if {winid} is invalid. 9562 9563]=] , 9564name ='screenpos' , 9565params ={ { 'winid' , 'integer' } , { 'lnum' , 'integer' } , { 'col' , 'integer' } } , 9566returns ='{ col: integer, curscol: integer, endcol: integer, row: integer }' , 9567signature ='screenpos({winid}, {lnum}, {col})' , 9568} , 9569screenrow ={ 9570desc =[=[ 9571Returns the current screen row of the cursor. The top line 9572has number one. 9573This function is mainly used for testing. 9574Alternatively you can use |winline()|. 9575 9576Note: Same restrictions as with |screencol()|. 9577]=] , 9578name ='screenrow' , 9579params ={} , 9580returns ='integer' , 9581signature ='screenrow()' , 9582} , 9583screenstring ={ 9584args =2 , 9585base =1 , 9586desc =[=[ 9587Returns the base character and any composing characters at 9588screen position [row, col] as a String. This is like 9589|screenchars()| but returning a String with the characters. 9590This is mainly to be used for testing. 9591Returns an empty String when row or col is out of range. 9592 9593]=] , 9594name ='screenstring' , 9595params ={ { 'row' , 'integer' } , { 'col' , 'integer' } } , 9596returns ='string' , 9597signature ='screenstring({row}, {col})' , 9598} , 9599search ={ 9600args ={ 1 , 5 } , 9601base =1 , 9602desc =[=[ 9603Search for regexp pattern {pattern}. The search starts at the 9604cursor position (you can use |cursor()| to set it). 9605 9606When a match has been found its line number is returned. 9607If there is no match a 0 is returned and the cursor doesn't 9608move. No error message is given. 9609To get the matched string, use |matchbufline()|. 9610 9611{flags} is a String, which can contain these character flags: 9612'b' search Backward instead of forward 9613'c' accept a match at the Cursor position 9614'e' move to the End of the match 9615'n' do Not move the cursor 9616'p' return number of matching sub-Pattern (see below) 9617's' Set the ' mark at the previous location of the cursor 9618'w' Wrap around the end of the file 9619'W' don't Wrap around the end of the file 9620'z' start searching at the cursor column instead of Zero 9621If neither 'w' or 'W' is given, the 'wrapscan' option applies. 9622 9623If the 's' flag is supplied, the ' mark is set, only if the 9624cursor is moved. The 's' flag cannot be combined with the 'n' 9625flag. 9626 9627'ignorecase', 'smartcase' and 'magic' are used. 9628 9629When the 'z' flag is not given, forward searching always 9630starts in column zero and then matches before the cursor are 9631skipped. When the 'c' flag is present in 'cpo' the next 9632search starts after the match. Without the 'c' flag the next 9633search starts one column after the start of the match. This 9634matters for overlapping matches. See |cpo-c|. You can also 9635insert "\ze" to change where the match ends, see |/\ze|. 9636 9637When searching backwards and the 'z' flag is given then the 9638search starts in column zero, thus no match in the current 9639line will be found (unless wrapping around the end of the 9640file). 9641 9642When the {stopline} argument is given then the search stops 9643after searching this line. This is useful to restrict the 9644search to a range of lines. Examples: >vim 9645let match = search('(', 'b', line("w0")) 9646let end = search('END', '', line("w$")) 9647<When {stopline} is used and it is not zero this also implies 9648that the search does not wrap around the end of the file. 9649A zero value is equal to not giving the argument. 9650 9651When the {timeout} argument is given the search stops when 9652more than this many milliseconds have passed. Thus when 9653{timeout} is 500 the search stops after half a second. 9654The value must not be negative. A zero value is like not 9655giving the argument. 9656 9657Note: the timeout is only considered when searching, not 9658while evaluating the {skip} expression. 9659 9660If the {skip} expression is given it is evaluated with the 9661cursor positioned on the start of a match. If it evaluates to 9662non-zero this match is skipped. This can be used, for 9663example, to skip a match in a comment or a string. 9664{skip} can be a string, which is evaluated as an expression, a 9665function reference or a lambda. 9666When {skip} is omitted or empty, every match is accepted. 9667When evaluating {skip} causes an error the search is aborted 9668and -1 returned. 9669*search()-sub-match* 9670With the 'p' flag the returned value is one more than the 9671first sub-match in \(\). One if none of them matched but the 9672whole pattern did match. 9673To get the column number too use |searchpos()|. 9674 9675The cursor will be positioned at the match, unless the 'n' 9676flag is used. 9677 9678Example (goes over all files in the argument list): >vim 9679let n = 1 9680while n <= argc() " loop over all files in arglist 9681exe "argument " .. n 9682" start at the last char in the file and wrap for the 9683" first search to find match at start of file 9684normal G$ 9685let flags = "w" 9686while search("foo", flags) > 0 9687s/foo/bar/g 9688let flags = "W" 9689endwhile 9690update " write the file if modified 9691let n = n + 1 9692endwhile 9693< 9694Example for using some flags: >vim 9695echo search('\<if\|\(else\)\|\(endif\)', 'ncpe') 9696<This will search for the keywords "if", "else", and "endif" 9697under or after the cursor. Because of the 'p' flag, it 9698returns 1, 2, or 3 depending on which keyword is found, or 0 9699if the search fails. With the cursor on the first word of the 9700line: 9701if (foo == 0) | let foo = foo + 1 | endif ~ 9702the function returns 1. Without the 'c' flag, the function 9703finds the "endif" and returns 3. The same thing happens 9704without the 'e' flag if the cursor is on the "f" of "if". 9705The 'n' flag tells the function not to move the cursor. 9706 9707]=] , 9708name ='search' , 9709params ={ 9710{ 'pattern' , 'string' } , 9711{ 'flags' , 'string' } , 9712{ 'stopline' , 'integer' } , 9713{ 'timeout' , 'integer' } , 9714{ 'skip' , 'string|function' } , 9715} , 9716returns ='integer' , 9717signature ='search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])' , 9718} , 9719searchcount ={ 9720args ={ 0 , 1 } , 9721base =1 , 9722desc =[=[ 9723Get or update the last search count, like what is displayed 9724without the "S" flag in 'shortmess'. This works even if 9725'shortmess' does contain the "S" flag. 9726 9727This returns a |Dictionary|. The dictionary is empty if the 9728previous pattern was not set and "pattern" was not specified. 9729 9730key type meaning ~ 9731current |Number| current position of match; 97320 if the cursor position is 9733before the first match 9734exact_match |Boolean| 1 if "current" is matched on 9735"pos", otherwise 0 9736total |Number| total count of matches found 9737incomplete |Number| 0: search was fully completed 97381: recomputing was timed out 97392: max count exceeded 9740 9741For {options} see further down. 9742 9743To get the last search count when |n| or |N| was pressed, call 9744this function with `recompute: 0` . This sometimes returns 9745wrong information because of 'maxsearchcount'. 9746If the count exceeded 'maxsearchcount', the result must be 9747'maxsearchcount' + 1. If you want to get correct information, 9748specify `recompute: 1`: >vim 9749 9750" result == 'maxsearchcount' + 1 when many matches 9751let result = searchcount(#{recompute: 0}) 9752 9753" Below returns correct result (recompute defaults 9754" to 1) 9755let result = searchcount() 9756< 9757The function is useful to add the count to 'statusline': >vim 9758function! LastSearchCount() abort 9759let result = searchcount(#{recompute: 0}) 9760if empty(result) 9761return '' 9762endif 9763if result.incomplete ==# 1 " timed out 9764return printf(' /%s [?/??]', @/) 9765elseif result.incomplete ==# 2 " max count exceeded 9766if result.total > result.maxcount && 9767\ result.current > result.maxcount 9768return printf(' /%s [>%d/>%d]', @/, 9769\ result.current, result.total) 9770elseif result.total > result.maxcount 9771return printf(' /%s [%d/>%d]', @/, 9772\ result.current, result.total) 9773endif 9774endif 9775return printf(' /%s [%d/%d]', @/, 9776\ result.current, result.total) 9777endfunction 9778let &statusline ..= '%{LastSearchCount()}' 9779 9780" Or if you want to show the count only when 9781" 'hlsearch' was on 9782" let &statusline ..= 9783" \ '%{v:hlsearch ? LastSearchCount() : ""}' 9784< 9785You can also update the search count, which can be useful in a 9786|CursorMoved| or |CursorMovedI| autocommand: >vim 9787 9788autocmd CursorMoved,CursorMovedI * 9789\ let s:searchcount_timer = timer_start( 9790\ 200, function('s:update_searchcount')) 9791function! s:update_searchcount(timer) abort 9792if a:timer ==# s:searchcount_timer 9793call searchcount(#{ 9794\ recompute: 1, maxcount: 0, timeout: 100}) 9795redrawstatus 9796endif 9797endfunction 9798< 9799This can also be used to count matched texts with specified 9800pattern in the current buffer using "pattern": >vim 9801 9802" Count '\<foo\>' in this buffer 9803" (Note that it also updates search count) 9804let result = searchcount(#{pattern: '\<foo\>'}) 9805 9806" To restore old search count by old pattern, 9807" search again 9808call searchcount() 9809< 9810{options} must be a |Dictionary|. It can contain: 9811key type meaning ~ 9812recompute |Boolean| if |TRUE|, recompute the count 9813like |n| or |N| was executed. 9814otherwise returns the last 9815computed result (when |n| or 9816|N| was used when "S" is not 9817in 'shortmess', or this 9818function was called). 9819(default: |TRUE|) 9820pattern |String| recompute if this was given 9821and different with |@/|. 9822this works as same as the 9823below command is executed 9824before calling this function >vim 9825let @/ = pattern 9826< (default: |@/|) 9827timeout |Number| 0 or negative number is no 9828timeout. timeout milliseconds 9829for recomputing the result 9830(default: 0) 9831maxcount |Number| 0 or negative number is no 9832limit. max count of matched 9833text while recomputing the 9834result. if search exceeded 9835total count, "total" value 9836becomes `maxcount + 1` 9837(default: 'maxsearchcount') 9838pos |List| `[lnum, col, off]` value 9839when recomputing the result. 9840this changes "current" result 9841value. see |cursor()|, |getpos()| 9842(default: cursor's position) 9843 9844]=] , 9845name ='searchcount' , 9846params ={ { 'options' , 'table' } } , 9847signature ='searchcount([{options}])' , 9848} , 9849searchdecl ={ 9850args ={ 1 , 3 } , 9851base =1 , 9852desc =[=[ 9853Search for the declaration of {name}. 9854 9855With a non-zero {global} argument it works like |gD|, find 9856first match in the file. Otherwise it works like |gd|, find 9857first match in the function. 9858 9859With a non-zero {thisblock} argument matches in a {} block 9860that ends before the cursor position are ignored. Avoids 9861finding variable declarations only valid in another scope. 9862 9863Moves the cursor to the found match. 9864Returns zero for success, non-zero for failure. 9865Example: >vim 9866if searchdecl('myvar') == 0 9867echo getline('.') 9868endif 9869< 9870]=] , 9871name ='searchdecl' , 9872params ={ { 'name' , 'string' } , { 'global' , 'boolean' } , { 'thisblock' , 'boolean' } } , 9873signature ='searchdecl({name} [, {global} [, {thisblock}]])' , 9874} , 9875searchpair ={ 9876args ={ 3 , 7 } , 9877desc =[=[ 9878Search for the match of a nested start-end pair. This can be 9879used to find the "endif" that matches an "if", while other 9880if/endif pairs in between are ignored. 9881The search starts at the cursor. The default is to search 9882forward, include 'b' in {flags} to search backward. 9883If a match is found, the cursor is positioned at it and the 9884line number is returned. If no match is found 0 or -1 is 9885returned and the cursor doesn't move. No error message is 9886given. 9887 9888{start}, {middle} and {end} are patterns, see |pattern|. They 9889must not contain \( \) pairs. Use of \%( \) is allowed. When 9890{middle} is not empty, it is found when searching from either 9891direction, but only when not in a nested start-end pair. A 9892typical use is: >vim 9893echo searchpair('\<if\>', '\<else\>', '\<endif\>') 9894<By leaving {middle} empty the "else" is skipped. 9895 9896{flags} 'b', 'c', 'n', 's', 'w' and 'W' are used like with 9897|search()|. Additionally: 9898'r' Repeat until no more matches found; will find the 9899outer pair. Implies the 'W' flag. 9900'm' Return number of matches instead of line number with 9901the match; will be > 1 when 'r' is used. 9902Note: it's nearly always a good idea to use the 'W' flag, to 9903avoid wrapping around the end of the file. 9904 9905When a match for {start}, {middle} or {end} is found, the 9906{skip} expression is evaluated with the cursor positioned on 9907the start of the match. It should return non-zero if this 9908match is to be skipped. E.g., because it is inside a comment 9909or a string. 9910When {skip} is omitted or empty, every match is accepted. 9911When evaluating {skip} causes an error the search is aborted 9912and -1 returned. 9913{skip} can be a string, a lambda, a funcref or a partial. 9914Anything else makes the function fail. 9915 9916For {stopline} and {timeout} see |search()|. 9917 9918The value of 'ignorecase' is used. 'magic' is ignored, the 9919patterns are used like it's on. 9920 9921The search starts exactly at the cursor. A match with 9922{start}, {middle} or {end} at the next character, in the 9923direction of searching, is the first one found. Example: >vim 9924if 1 9925if 2 9926endif 2 9927endif 1 9928<When starting at the "if 2", with the cursor on the "i", and 9929searching forwards, the "endif 2" is found. When starting on 9930the character just before the "if 2", the "endif 1" will be 9931found. That's because the "if 2" will be found first, and 9932then this is considered to be a nested if/endif from "if 2" to 9933"endif 2". 9934When searching backwards and {end} is more than one character, 9935it may be useful to put "\zs" at the end of the pattern, so 9936that when the cursor is inside a match with the end it finds 9937the matching start. 9938 9939Example, to find the "endif" command in a Vim script: >vim 9940 9941echo searchpair('\<if\>', '\<el\%[seif]\>', '\<en\%[dif]\>', 'W', 9942\ 'getline(".") =~ "^\\s*\""') 9943 9944<The cursor must be at or after the "if" for which a match is 9945to be found. Note that single-quote strings are used to avoid 9946having to double the backslashes. The skip expression only 9947catches comments at the start of a line, not after a command. 9948Also, a word "en" or "if" halfway through a line is considered 9949a match. 9950Another example, to search for the matching "{" of a "}": >vim 9951 9952echo searchpair('{', '', '}', 'bW') 9953 9954<This works when the cursor is at or before the "}" for which a 9955match is to be found. To reject matches that syntax 9956highlighting recognized as strings: >vim 9957 9958echo searchpair('{', '', '}', 'bW', 9959\ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"') 9960< 9961]=] , 9962name ='searchpair' , 9963params ={ 9964{ 'start' , 'string' } , 9965{ 'middle' , 'string' } , 9966{ 'end' , 'string' } , 9967{ 'flags' , 'string' } , 9968{ 'skip' , 'string|function' } , 9969{ 'stopline' , 'integer' } , 9970{ 'timeout' , 'integer' } , 9971} , 9972returns ='integer' , 9973signature ='searchpair({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeout}]]]])' , 9974} , 9975searchpairpos ={ 9976args ={ 3 , 7 } , 9977desc =[=[ 9978Same as |searchpair()|, but returns a |List| with the line and 9979column position of the match. The first element of the |List| 9980is the line number and the second element is the byte index of 9981the column position of the match. If no match is found, 9982returns [0, 0]. >vim 9983 9984let [lnum,col] = searchpairpos('{', '', '}', 'n') 9985< 9986See |match-parens| for a bigger and more useful example. 9987]=] , 9988name ='searchpairpos' , 9989params ={ 9990{ 'start' , 'string' } , 9991{ 'middle' , 'string' } , 9992{ 'end' , 'string' } , 9993{ 'flags' , 'string' } , 9994{ 'skip' , 'string|function' } , 9995{ 'stopline' , 'integer' } , 9996{ 'timeout' , 'integer' } , 9997} , 9998returns ='[integer, integer]' , 9999signature ='searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeout}]]]])' , 10000} , 10001searchpos ={ 10002args ={ 1 , 5 } , 10003base =1 , 10004desc =[=[ 10005Same as |search()|, but returns a |List| with the line and 10006column position of the match. The first element of the |List| 10007is the line number and the second element is the byte index of 10008the column position of the match. If no match is found, 10009returns [0, 0]. 10010Example: >vim 10011let [lnum, col] = searchpos('mypattern', 'n') 10012 10013<When the 'p' flag is given then there is an extra item with 10014the sub-pattern match number |search()-sub-match|. Example: >vim 10015let [lnum, col, submatch] = searchpos('\(\l\)\|\(\u\)', 'np') 10016<In this example "submatch" is 2 when a lowercase letter is 10017found |/\l|, 3 when an uppercase letter is found |/\u|. 10018 10019]=] , 10020name ='searchpos' , 10021params ={ 10022{ 'pattern' , 'string' } , 10023{ 'flags' , 'string' } , 10024{ 'stopline' , 'integer' } , 10025{ 'timeout' , 'integer' } , 10026{ 'skip' , 'string|function' } , 10027} , 10028returns ='{ [1]: integer, [2]: integer, [3]: integer? }' , 10029signature ='searchpos({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])' , 10030} , 10031serverlist ={ 10032args ={ 0 , 1 } , 10033desc =[=[ 10034Returns a list of server addresses, or empty if all servers 10035were stopped. |serverstart()| |serverstop()| 10036 10037The optional argument {opts} is a Dict and supports the following items: 10038 10039peer : If |TRUE|, servers not started by |serverstart()| 10040will also be returned. (default: |FALSE|) 10041Not supported on Windows yet. 10042 10043info : If |TRUE|, return a list of Dicts with detailed info 10044instead of addresses. Implies `peer=true`. Each Dict 10045has the following items: 10046addr (string) Server address. 10047pid (number) PID of the Nvim process. 10048own (bool) Whether this server belongs to 10049the current Nvim instance. 10050active (number) |v:useractive| of the server. 10051(default: |FALSE|) 10052 10053Example: >vim 10054echo serverlist() 10055echo serverlist(#{info: v:true}) 10056< 10057]=] , 10058name ='serverlist' , 10059params ={ { 'opts' , 'table' } } , 10060returns ='string[]|vim.ServerInfo[]' , 10061signature ='serverlist([{opts}])' , 10062} , 10063serverstart ={ 10064args ={ 0 , 1 } , 10065desc =[=[ 10066Opens a socket or named pipe at {address} and listens for 10067|RPC| messages. Clients can send |API| commands to the 10068returned address to control Nvim. 10069 10070Returns the address string (which may differ from the 10071{address} argument, see below). 10072 10073- If {address} has a colon (":") it is a TCP/IPv4/IPv6 address 10074where the last ":" separates host and port (empty or zero 10075assigns a random port). 10076- Else {address} is the path to a named pipe (except on Windows). 10077- If {address} has no slashes ("/") it is treated as the 10078"name" part of a generated path in this format: >vim 10079stdpath("run").."/{name}.{pid}.{counter}" 10080< - If {address} is omitted the name is "nvim". >vim 10081echo serverstart() 10082< > 10083=> /tmp/nvim.bram/oknANW/nvim.15430.5 10084< 10085Example bash command to list all Nvim servers: >bash 10086ls ${XDG_RUNTIME_DIR:-${TMPDIR}nvim.${USER}}/*/nvim.*.0 10087 10088<Example named pipe: >vim 10089if has('win32') 10090echo serverstart('//./pipe/nvim-pipe-1234') 10091else 10092echo serverstart('nvim.sock') 10093endif 10094< 10095Example TCP/IP address: >vim 10096echo serverstart('::1:12345') 10097< 10098]=] , 10099name ='serverstart' , 10100params ={ { 'address' , 'string' } } , 10101returns ='string' , 10102signature ='serverstart([{address}])' , 10103} , 10104serverstop ={ 10105args =1 , 10106desc =[=[ 10107Closes the pipe or socket at {address}. 10108Returns TRUE if {address} is valid, else FALSE. 10109If |v:servername| is stopped it is set to the next available 10110address in |serverlist()|. 10111]=] , 10112name ='serverstop' , 10113params ={ { 'address' , 'string' } } , 10114returns ='integer' , 10115signature ='serverstop({address})' , 10116} , 10117setbufline ={ 10118args =3 , 10119base =3 , 10120desc =[=[ 10121Set line {lnum} to {text} in buffer {buf}. This works like 10122|setline()| for the specified buffer. 10123 10124This function works only for loaded buffers. First call 10125|bufload()| if needed. 10126 10127To insert lines use |appendbufline()|. 10128 10129{text} can be a string to set one line, or a List of strings 10130to set multiple lines. If the List extends below the last 10131line then those lines are added. If the List is empty then 10132nothing is changed and zero is returned. 10133 10134For the use of {buf}, see |bufname()| above. 10135 10136{lnum} is used like with |setline()|. 10137Use "$" to refer to the last line in buffer {buf}. 10138When {lnum} is just below the last line the {text} will be 10139added below the last line. 10140On success 0 is returned, on failure 1 is returned. 10141 10142If {buf} is not a valid buffer or {lnum} is not valid, an 10143error message is given. 10144 10145]=] , 10146name ='setbufline' , 10147params ={ { 'buf' , 'integer|string' } , { 'lnum' , 'integer' } , { 'text' , 'string|string[]' } } , 10148returns ='integer' , 10149signature ='setbufline({buf}, {lnum}, {text})' , 10150see_lua ={ '|nvim_buf_set_lines()|' } , 10151} , 10152setbufvar ={ 10153args =3 , 10154base =3 , 10155desc =[=[ 10156Set option or local variable {varname} (string, without "b:") 10157in buffer {buf} to {val}. Also works for a global or 10158window-local option (not variable). A window-local option is 10159set in a window of the current tabpage that displays {buf}, 10160and the global value is unchanged. When no window in the 10161current tabpage displays {buf} the option is not set and no 10162error is given; use |setwinvar()| or |win_execute()| for that. 10163 10164For the use of {buf}, see |bufname()| above. 10165 10166Examples: >vim 10167call setbufvar(1, "&mod", 1) 10168call setbufvar("todo", "myvar", "foobar") 10169<This function is not available in the |sandbox|. 10170 10171]=] , 10172name ='setbufvar' , 10173params ={ { 'buf' , 'integer|string' } , { 'varname' , 'string' } , { 'val' , 'any' } } , 10174signature ='setbufvar({buf}, {varname}, {val})' , 10175see_lua ={ 10176'|nvim_buf_set_var()| or |vim.b| after resolving {buf} to a bufnr; option names use |nvim_set_option_value()|' , 10177} , 10178} , 10179setcellwidths ={ 10180args =1 , 10181base =1 , 10182desc =[=[ 10183Specify overrides for cell widths of character ranges. This 10184tells Vim how wide characters are when displayed in the 10185terminal, counted in screen cells. The values override 10186'ambiwidth'. Example: >vim 10187call setcellwidths([ 10188\ [0x111, 0x111, 1], 10189\ [0x2194, 0x2199, 2], 10190\ ]) 10191 10192<The {list} argument is a List of Lists with each three 10193numbers: [{low}, {high}, {width}]. *E1109* *E1110* 10194{low} and {high} can be the same, in which case this refers to 10195one character. Otherwise it is the range of characters from 10196{low} to {high} (inclusive). *E1111* *E1114* 10197Only characters with value 0x80 and higher can be used. 10198 10199{width} must be either 1 or 2, indicating the character width 10200in screen cells. *E1112* 10201An error is given if the argument is invalid, also when a 10202range overlaps with another. *E1113* 10203 10204If the new value causes 'fillchars' or 'listchars' to become 10205invalid it is rejected and an error is given. 10206 10207To clear the overrides pass an empty {list}: >vim 10208call setcellwidths([]) 10209 10210<You can use the script $VIMRUNTIME/scripts/emoji_list.lua to see 10211the effect for known emoji characters. Move the cursor 10212through the text to check if the cell widths of your terminal 10213match with what Vim knows about each emoji. If it doesn't 10214look right you need to adjust the {list} argument. 10215 10216|getcellwidths()| can be used to get the overrides later. 10217]=] , 10218name ='setcellwidths' , 10219params ={ { 'list' , 'any[]' } } , 10220signature ='setcellwidths({list})' , 10221} , 10222setcharpos ={ 10223args =2 , 10224base =2 , 10225desc =[=[ 10226Same as |setpos()| but uses the specified column number as the 10227character index instead of the byte index in the line. 10228 10229Example: 10230With the text "여보세요" in line 8: >vim 10231call setcharpos('.', [0, 8, 4, 0]) 10232<positions the cursor on the fourth character '요'. >vim 10233call setpos('.', [0, 8, 4, 0]) 10234<positions the cursor on the second character '보'. 10235 10236]=] , 10237name ='setcharpos' , 10238params ={ { 'expr' , 'string' } , { 'list' , 'integer[]' } } , 10239signature ='setcharpos({expr}, {list})' , 10240see_lua ={ 10241'|nvim_win_set_cursor()| or |nvim_buf_set_mark()| with |vim.str_byteindex()|; special positions, `off`, and `curswant` differ' , 10242} , 10243} , 10244setcharsearch ={ 10245args =1 , 10246base =1 , 10247desc =[=[ 10248Set the current character search information to {dict}, 10249which contains one or more of the following entries: 10250 10251char character which will be used for a subsequent 10252|,| or |;| command; an empty string clears the 10253character search 10254forward direction of character search; 1 for forward, 102550 for backward 10256until type of character search; 1 for a |t| or |T| 10257character search, 0 for an |f| or |F| 10258character search 10259 10260This can be useful to save/restore a user's character search 10261from a script: >vim 10262let prevsearch = getcharsearch() 10263" Perform a command which clobbers user's search 10264call setcharsearch(prevsearch) 10265<Also see |getcharsearch()|. 10266 10267]=] , 10268name ='setcharsearch' , 10269params ={ { 'dict' , '{ char?: string, forward?: 1|0, until?: 1|0 }' } } , 10270signature ='setcharsearch({dict})' , 10271} , 10272setcmdline ={ 10273args ={ 1 , 2 } , 10274base =1 , 10275desc =[=[ 10276Set the command line to {str} and set the cursor position to 10277{pos}. 10278If {pos} is omitted, the cursor is positioned after the text. 10279Returns 0 when successful, 1 when not editing the command 10280line. 10281 10282]=] , 10283name ='setcmdline' , 10284params ={ { 'str' , 'string' } , { 'pos' , 'integer' } } , 10285returns ='integer' , 10286signature ='setcmdline({str} [, {pos}])' , 10287} , 10288setcmdpos ={ 10289args =1 , 10290base =1 , 10291desc =[=[ 10292Set the cursor position in the command line to byte position 10293{pos}. The first position is 1. 10294Use |getcmdpos()| to obtain the current position. 10295Only works while editing the command line, thus you must use 10296|c_CTRL-\_e|, |c_CTRL-R_=| or |c_CTRL-R_CTRL-R| with '='. For 10297|c_CTRL-\_e| and |c_CTRL-R_CTRL-R| with '=' the position is 10298set after the command line is set to the expression. For 10299|c_CTRL-R_=| it is set after evaluating the expression but 10300before inserting the resulting text. 10301When the number is too big the cursor is put at the end of the 10302line. A number smaller than one has undefined results. 10303Returns 0 when successful, 1 when not editing the command 10304line. 10305 10306]=] , 10307name ='setcmdpos' , 10308params ={ { 'pos' , 'integer' } } , 10309signature ='setcmdpos({pos})' , 10310} , 10311setcursorcharpos ={ 10312args ={ 1 , 3 } , 10313base =1 , 10314name ='setcursorcharpos' , 10315params ={ { 'lnum' , 'integer|string' } , { 'col' , 'integer' } , { 'off' , 'integer' } } , 10316signature ='setcursorcharpos({lnum}, {col} [, {off}])' , 10317see_lua ={ 10318'|nvim_win_set_cursor()| with |vim.str_byteindex()|; `off`, return values, and special line forms differ' , 10319} , 10320} , 10321setcursorcharpos__1 ={ 10322args ={ 1 , 3 } , 10323base =1 , 10324desc =[=[ 10325Same as |cursor()| but uses the specified column number as the 10326character index instead of the byte index in the line. 10327 10328Example: 10329With the text "여보세요" in line 4: >vim 10330call setcursorcharpos(4, 3) 10331<positions the cursor on the third character '세'. >vim 10332call cursor(4, 3) 10333<positions the cursor on the first character '여'. 10334 10335Returns 0 when the position could be set, -1 otherwise. 10336]=] , 10337name ='setcursorcharpos' , 10338params ={ { 'list' , 'integer[]' } } , 10339signature ='setcursorcharpos({list})' , 10340see_lua ={ 10341'|nvim_win_set_cursor()| with |vim.str_byteindex()|; list shape, `off`, and return values differ' , 10342} , 10343} , 10344setenv ={ 10345args =2 , 10346base =2 , 10347desc =[=[ 10348Set environment variable {name} to {val}. Example: >vim 10349call setenv('HOME', '/home/myhome') 10350 10351<When {val} is |v:null| the environment variable is deleted. 10352See also |expr-env|. 10353 10354]=] , 10355name ='setenv' , 10356params ={ { 'name' , 'string' } , { 'val' , 'string' } } , 10357signature ='setenv({name}, {val})' , 10358see_lua ={ '|vim.env|' } , 10359} , 10360setfperm ={ 10361args =2 , 10362base =1 , 10363tags ={ 'chmod' } , 10364desc =[=[ 10365Set the file permissions for {fname} to {mode}. 10366{mode} must be a string with 9 characters. It is of the form 10367"rwxrwxrwx", where each group of "rwx" flags represent, in 10368turn, the permissions of the owner of the file, the group the 10369file belongs to, and other users. A '-' character means the 10370permission is off, any other character means on. Multi-byte 10371characters are not supported. 10372 10373For example "rw-r-----" means read-write for the user, 10374readable by the group, not accessible by others. "xx-x-----" 10375would do the same thing. 10376 10377Returns non-zero for success, zero for failure. 10378 10379To read permissions see |getfperm()|. 10380]=] , 10381name ='setfperm' , 10382params ={ { 'fname' , 'string' } , { 'mode' , 'string' } } , 10383signature ='setfperm({fname}, {mode})' , 10384see_lua ={ '|uv.fs_chmod()|' } , 10385} , 10386setline ={ 10387args =2 , 10388base =2 , 10389desc =[=[ 10390Set line {lnum} of the current buffer to {text}. To insert 10391lines use |append()|. To set lines in another buffer use 10392|setbufline()|. 10393 10394{lnum} is used like with |getline()|. 10395When {lnum} is just below the last line the {text} will be 10396added below the last line. 10397{text} can be any type or a List of any type, each item is 10398converted to a String. When {text} is an empty List then 10399nothing is changed and FALSE is returned. 10400 10401If this succeeds, FALSE is returned. If this fails (most 10402likely because {lnum} is invalid) TRUE is returned. 10403 10404Example: >vim 10405call setline(5, strftime("%c")) 10406 10407<When {text} is a |List| then line {lnum} and following lines 10408will be set to the items in the list. Example: >vim 10409call setline(5, ['aaa', 'bbb', 'ccc']) 10410<This is equivalent to: >vim 10411for [n, l] in [[5, 'aaa'], [6, 'bbb'], [7, 'ccc']] 10412call setline(n, l) 10413endfor 10414 10415<Note: The '[ and '] marks are not set. 10416 10417]=] , 10418name ='setline' , 10419params ={ { 'lnum' , 'integer|string' } , { 'text' , 'any' } } , 10420signature ='setline({lnum}, {text})' , 10421see_lua ={ '|nvim_set_current_line()|' , '|nvim_buf_set_lines()|' } , 10422} , 10423setloclist ={ 10424args ={ 2 , 4 } , 10425base =2 , 10426desc =[=[ 10427Create or replace or add to the location list for window {nr} 10428(|window-number| or |window-ID|). 10429When {nr} is zero the current window is used. 10430 10431For a location list window, the displayed location list is 10432modified. For an invalid {nr}, -1 is returned. 10433Otherwise, same as |setqflist()|. 10434Also see |location-list|. 10435 10436For {action} see |setqflist-action|. 10437 10438If the optional {what} dictionary argument is supplied, then 10439only the items listed in {what} are set. Refer to |setqflist()| 10440for the list of supported keys in {what}. 10441 10442]=] , 10443name ='setloclist' , 10444params ={ 10445{ 'nr' , 'integer' } , 10446{ 'list' , 'vim.quickfix.entry[]' } , 10447{ 'action' , 'string' } , 10448{ 'what' , 'vim.fn.setqflist.what' } , 10449} , 10450signature ='setloclist({nr}, {list} [, {action} [, {what}]])' , 10451} , 10452setmatches ={ 10453args ={ 1 , 2 } , 10454base =1 , 10455desc =[=[ 10456Restores a list of matches saved by |getmatches()| for the 10457current window. Returns 0 if successful, otherwise -1. All 10458current matches are cleared before the list is restored. See 10459example for |getmatches()|. 10460{win} (if given) is a |window-number| or |window-ID|. 10461 10462]=] , 10463name ='setmatches' , 10464params ={ { 'list' , 'vim.fn.getmatches.ret.item[]' } , { 'win' , 'integer' } } , 10465signature ='setmatches({list} [, {win}])' , 10466} , 10467setpos ={ 10468args =2 , 10469base =2 , 10470desc =[=[ 10471Set the position for String {expr}. Possible values: 10472. the cursor 10473'x mark x 10474 10475{list} must be a |List| with four or five numbers: 10476[bufnum, lnum, col, off] 10477[bufnum, lnum, col, off, curswant] 10478 10479"bufnum" is the buffer number. Zero can be used for the 10480current buffer. When setting an uppercase mark "bufnum" is 10481used for the mark position. For other marks it specifies the 10482buffer to set the mark in. You can use the |bufnr()| function 10483to turn a file name into a buffer number. 10484For setting the cursor and the ' mark "bufnum" is ignored, 10485since these are associated with a window, not a buffer. 10486Does not change the jumplist. 10487 10488"lnum" and "col" are the position in the buffer. The first 10489column is 1. Use a zero "lnum" to delete a mark. If "col" is 10490smaller than 1 then 1 is used. To use the character count 10491instead of the byte count, use |setcharpos()|. 10492 10493The "off" number is only used when 'virtualedit' is set. Then 10494it is the offset in screen columns from the start of the 10495character. E.g., a position within a <Tab> or after the last 10496character. 10497 10498The "curswant" number is only used when setting the cursor 10499position. It sets the preferred column for when moving the 10500cursor vertically. When the "curswant" number is missing the 10501preferred column is not set. When it is present and setting a 10502mark position it is not used. 10503 10504Note that for |'<| and |'>| changing the line number may 10505result in the marks to be effectively swapped, so that |'<| is 10506always before |'>|. 10507 10508The visual marks |'<| and |'>| refer to the beginning and end 10509of the visual selection relative to the cursor position. 10510Note that this differs from |getpos()|, where they are 10511relative to the buffer. 10512 10513Returns 0 when the position could be set, -1 otherwise. 10514An error message is given if {expr} is invalid. 10515 10516Also see |setcharpos()|, |getpos()| and |getcurpos()|. 10517 10518This does not restore the preferred column for moving 10519vertically; if you set the cursor position with this, |j| and 10520|k| motions will jump to previous columns! Use |cursor()| to 10521also set the preferred column. Also see the "curswant" key in 10522|winrestview()|. 10523 10524]=] , 10525name ='setpos' , 10526params ={ { 'expr' , 'string' } , { 'list' , 'integer[]' } } , 10527signature ='setpos({expr}, {list})' , 10528see_lua ={ 10529'|nvim_win_set_cursor()| for "." or |nvim_buf_set_mark()| for marks; special positions, `off`, and `curswant` differ' , 10530} , 10531} , 10532setqflist ={ 10533args ={ 1 , 3 } , 10534base =1 , 10535desc =[=[ 10536Create or replace or add to the quickfix list. 10537 10538If the optional {what} dictionary argument is supplied, then 10539only the items listed in {what} are set. The first {list} 10540argument is ignored. See below for the supported items in 10541{what}. 10542*setqflist-what* 10543When {what} is not present, the items in {list} are used. 10544Each item must be a dictionary. Non-dictionary items in 10545{list} are ignored. Each dictionary item can contain the 10546following entries: 10547 10548bufnr buffer number; must be the number of a valid 10549buffer 10550filename name of a file; only used when "bufnr" is not 10551present or it is invalid. 10552module name of a module; if given it will be used in 10553quickfix error window instead of the filename. 10554lnum line number in the file 10555end_lnum end of lines, if the item spans multiple lines 10556pattern search pattern used to locate the error 10557col column number 10558vcol when non-zero: "col" is visual column 10559when zero: "col" is byte index 10560end_col end column, if the item spans multiple columns 10561nr error number 10562text description of the error 10563type single-character error type, 'E', 'W', etc. 10564valid recognized error message 10565user_data 10566custom data associated with the item, can be 10567any type. 10568 10569The "col", "vcol", "nr", "type" and "text" entries are 10570optional. Either "lnum" or "pattern" entry can be used to 10571locate a matching error line. 10572If the "filename" and "bufnr" entries are not present or 10573neither the "lnum" or "pattern" entries are present, then the 10574item will not be handled as an error line. 10575If both "pattern" and "lnum" are present then "pattern" will 10576be used. 10577If the "valid" entry is not supplied, then the valid flag is 10578set when "bufnr" is a valid buffer or "filename" exists. 10579If you supply an empty {list}, the quickfix list will be 10580cleared. 10581Note that the list is not exactly the same as what 10582|getqflist()| returns. 10583 10584{action} values: *setqflist-action* *E927* 10585'a' The items from {list} are added to the existing 10586quickfix list. If there is no existing list, then a 10587new list is created. 10588 10589'r' The items from the current quickfix list are replaced 10590with the items from {list}. This can also be used to 10591clear the list: >vim 10592call setqflist([], 'r') 10593< 10594'u' Like 'r', but tries to preserve the current selection 10595in the quickfix list. The entry nearest to the 10596previously selected one becomes the current entry. 10597Proximity is determined by comparing the file, then 10598the line number and then the column number. 10599'f' All the quickfix lists in the quickfix stack are 10600freed. 10601 10602If {action} is not present or is set to ' ', then a new list 10603is created. The new quickfix list is added after the current 10604quickfix list in the stack and all the following lists are 10605freed. To add a new quickfix list at the end of the stack, 10606set "nr" in {what} to "$". 10607 10608The following items can be specified in dictionary {what}: 10609context quickfix list context. See |quickfix-context| 10610efm errorformat to use when parsing text from 10611"lines". If this is not present, then the 10612'errorformat' option value is used. 10613See |quickfix-parse| 10614id quickfix list identifier |quickfix-ID| 10615idx index of the current entry in the quickfix 10616list specified by "id" or "nr". If set to 10617'$', then the last entry in the list is set as 10618the current entry. See |quickfix-index| 10619items list of quickfix entries. Same as the {list} 10620argument. 10621lines use 'errorformat' to parse a list of lines and 10622add the resulting entries to the quickfix list 10623{nr} or {id}. Only a |List| value is supported. 10624See |quickfix-parse| 10625nr list number in the quickfix stack; zero 10626means the current quickfix list and "$" means 10627the last quickfix list. 10628quickfixtextfunc 10629function to get the text to display in the 10630quickfix window. The value can be the name of 10631a function or a funcref or a lambda. Refer to 10632|quickfix-window-function| for an explanation 10633of how to write the function and an example. 10634title quickfix list title text. See |quickfix-title| 10635Unsupported keys in {what} are ignored. 10636If the "nr" item is not present, then the current quickfix 10637list is modified. When creating a new quickfix list, "nr" can 10638be set to a value one greater than the quickfix stack size. 10639When modifying a quickfix list, to guarantee that the correct 10640list is modified, "id" should be used instead of "nr" to 10641specify the list. 10642 10643Examples (See also |setqflist-examples|): >vim 10644call setqflist([], 'r', {'title': 'My search'}) 10645call setqflist([], 'r', {'nr': 2, 'title': 'Errors'}) 10646call setqflist([], 'a', {'id':qfid, 'lines':["F1:10:L10"]}) 10647< 10648Returns zero for success, -1 for failure. 10649 10650This function can be used to create a quickfix list 10651independent of the 'errorformat' setting. Use a command like 10652`:cc 1` to jump to the first position. 10653 10654]=] , 10655name ='setqflist' , 10656params ={ 10657{ 'list' , 'vim.quickfix.entry[]' } , 10658{ 'action' , 'string' } , 10659{ 'what' , 'vim.fn.setqflist.what' } , 10660} , 10661returns ='integer' , 10662signature ='setqflist({list} [, {action} [, {what}]])' , 10663} , 10664setreg ={ 10665args ={ 2 , 3 } , 10666base =2 , 10667desc =[=[ 10668Set the register {regname} to {value}. 10669If {regname} is "" or "@", the unnamed register '"' is used. 10670The {regname} argument is a string. 10671 10672{value} may be any value returned by |getreg()| or 10673|getreginfo()|, including a |List| or |Dict|. 10674If {options} contains "a" or {regname} is upper case, 10675then the value is appended. 10676 10677{options} can also contain a register type specification: 10678"c" or "v" |charwise| mode 10679"l" or "V" |linewise| mode 10680"b" or "<CTRL-V>" |blockwise-visual| mode 10681If a number immediately follows "b" or "<CTRL-V>" then this is 10682used as the width of the selection - if it is not specified 10683then the width of the block is set to the number of characters 10684in the longest line (counting a <Tab> as 1 character). 10685If {options} contains "u" or '"', then the unnamed register is 10686set to point to register {regname}. 10687 10688If {options} contains no register settings, then the default 10689is to use character mode unless {value} ends in a <NL> for 10690string {value} and linewise mode for list {value}. Blockwise 10691mode is never selected automatically. 10692Returns zero for success, non-zero for failure. 10693 10694*E883* 10695Note: you may not use |List| containing more than one item to 10696set search and expression registers. Lists containing 10697no items act like empty strings. 10698 10699Examples: >vim 10700call setreg(v:register, @*) 10701call setreg('*', @%, 'ac') 10702call setreg('a', "1\n2\n3", 'b5') 10703call setreg('"', { 'points_to': 'a'}) 10704 10705<This example shows using the functions to save and restore a 10706register: >vim 10707let var_a = getreginfo() 10708call setreg('a', var_a) 10709<or: >vim 10710let var_a = getreg('a', 1, 1) 10711let var_amode = getregtype('a') 10712" .... 10713call setreg('a', var_a, var_amode) 10714<Note: you may not reliably restore register value 10715without using the third argument to |getreg()| as without it 10716newlines are represented as newlines AND Nul bytes are 10717represented as newlines as well, see |NL-used-for-Nul|. 10718 10719You can also change the type of a register by appending 10720nothing: >vim 10721call setreg('a', '', 'al') 10722< 10723]=] , 10724name ='setreg' , 10725params ={ { 'regname' , 'string' } , { 'value' , 'any' } , { 'options' , 'string' } } , 10726signature ='setreg({regname}, {value} [, {options}])' , 10727} , 10728settabvar ={ 10729args =3 , 10730base =3 , 10731desc =[=[ 10732Set tab-local variable {varname} to {val} in tabpage {tabnr}. 10733|t:var| 10734The {varname} argument is a string. 10735Note that the variable name without "t:" must be used. 10736Tabs are numbered starting with one. 10737This function is not available in the |sandbox|. 10738 10739]=] , 10740name ='settabvar' , 10741params ={ { 'tabnr' , 'integer' } , { 'varname' , 'string' } , { 'val' , 'any' } } , 10742signature ='settabvar({tabnr}, {varname}, {val})' , 10743see_lua ={ '|nvim_tabpage_set_var()|' , '|vim.t|' } , 10744} , 10745settabwinvar ={ 10746args =4 , 10747base =4 , 10748desc =[=[ 10749Set option or local variable {varname} in window {winnr} to 10750{val}. 10751Tabs are numbered starting with one. For the current tabpage 10752use |setwinvar()|. 10753{winnr} is a |window-number| or |window-ID|. 10754When {winnr} is zero the current window is used. 10755This also works for a global or local buffer option, but it 10756doesn't work for a global or local buffer variable. 10757For a local buffer option the global value is unchanged. 10758Note that the variable name without "w:" must be used. 10759Examples: >vim 10760call settabwinvar(1, 1, "&list", 0) 10761call settabwinvar(3, 2, "myvar", "foobar") 10762<This function is not available in the |sandbox|. 10763 10764]=] , 10765name ='settabwinvar' , 10766params ={ 10767{ 'tabnr' , 'integer' } , 10768{ 'winnr' , 'integer' } , 10769{ 'varname' , 'string' } , 10770{ 'val' , 'any' } , 10771} , 10772signature ='settabwinvar({tabnr}, {winnr}, {varname}, {val})' , 10773see_lua ={ 10774'|nvim_win_set_var()| or |vim.w| after resolving {tabnr} and {winnr} to a winid; option names use |nvim_set_option_value()|' , 10775} , 10776} , 10777settagstack ={ 10778args ={ 2 , 3 } , 10779base =2 , 10780desc =[=[ 10781Modify the tag stack of the window {nr} (|window-number| or 10782|window-ID|) using {dict}. 10783 10784For a list of supported items in {dict}, refer to 10785|gettagstack()|. "curidx" takes effect before changing the tag 10786stack. 10787*E962* 10788How the tag stack is modified depends on the {action} 10789argument: 10790- If {action} is not present or is set to 'r', then the tag 10791stack is replaced. 10792- If {action} is set to 'a', then new entries from {dict} are 10793pushed (added) onto the tag stack. 10794- If {action} is set to 't', then all the entries from the 10795current entry in the tag stack or "curidx" in {dict} are 10796removed and then new entries are pushed to the stack. 10797 10798The current index is set to one after the length of the tag 10799stack after the modification. 10800 10801Returns zero for success, -1 for failure. 10802 10803Examples (for more examples see |tagstack-examples|): 10804Empty the tag stack of window 3: >vim 10805call settagstack(3, {'items' : []}) 10806 10807< Save and restore the tag stack: >vim 10808let stack = gettagstack(1003) 10809" do something else 10810call settagstack(1003, stack) 10811unlet stack 10812< 10813]=] , 10814name ='settagstack' , 10815params ={ { 'nr' , 'integer' } , { 'dict' , 'any' } , { 'action' , 'string' } } , 10816signature ='settagstack({nr}, {dict} [, {action}])' , 10817} , 10818setwinvar ={ 10819args =3 , 10820base =3 , 10821desc =[=[ 10822Like |settabwinvar()| for the current tabpage. 10823Examples: >vim 10824call setwinvar(1, "&list", 0) 10825call setwinvar(2, "myvar", "foobar") 10826< 10827]=] , 10828name ='setwinvar' , 10829params ={ { 'nr' , 'integer' } , { 'varname' , 'string' } , { 'val' , 'any' } } , 10830signature ='setwinvar({nr}, {varname}, {val})' , 10831see_lua ={ 10832'|nvim_win_set_var()| or |vim.w| after resolving {nr} to a winid; option names use |nvim_set_option_value()|' , 10833} , 10834} , 10835sha256 ={ 10836args =1 , 10837base =1 , 10838desc =[=[ 10839Returns a String with 64 hex characters, which is the SHA256 10840checksum of {expr}. 10841{expr} is a String or a Blob. 10842 10843]=] , 10844name ='sha256' , 10845params ={ { 'expr' , 'string' } } , 10846returns ='string' , 10847signature ='sha256({expr})' , 10848} , 10849shellescape ={ 10850args ={ 1 , 2 } , 10851base =1 , 10852desc =[=[ 10853Escape {string} for use as a shell command argument. 10854 10855On Windows when 'shellslash' is not set, encloses {string} in 10856double-quotes and doubles all double-quotes within {string}. 10857Otherwise encloses {string} in single-quotes and replaces all 10858"'" with "'\''". 10859 10860The {special} argument adds additional escaping of keywords 10861used in Vim commands. If it is a |non-zero-arg|: 10862- Special items such as "!", "%", "#" and "<cword>" (as listed 10863in |expand()|) will be preceded by a backslash. 10864The backslash will be removed again by the |:!| command. 10865- The <NL> character is escaped. 10866 10867If 'shell' contains "csh" in the tail: 10868- The "!" character will be escaped. This is because csh and 10869tcsh use "!" for history replacement even in single-quotes. 10870- The <NL> character is escaped (twice if {special} is 10871a |non-zero-arg|). 10872 10873If 'shell' contains "fish" in the tail, the "\" character will 10874be escaped because in fish it is used as an escape character 10875inside single quotes. 10876 10877Example of use with a |:!| command: >vim 10878exe '!dir ' .. shellescape(expand('<cfile>'), 1) 10879<This results in a directory listing for the file under the 10880cursor. Example of use with |system()|: >vim 10881call system("chmod +w -- " .. shellescape(expand("%"))) 10882<See also |::S|. 10883 10884]=] , 10885name ='shellescape' , 10886params ={ { 'string' , 'string' } , { 'special' , 'boolean' } } , 10887returns ='string' , 10888signature ='shellescape({string} [, {special}])' , 10889see_lua ={ 10890'|vim.system()| with list args to avoid shell escaping; `:!` and {special} semantics differ' , 10891} , 10892} , 10893shiftwidth ={ 10894args ={ 0 , 1 } , 10895base =1 , 10896desc =[=[ 10897Returns the effective value of 'shiftwidth'. This is the 10898'shiftwidth' value unless it is zero, in which case it is the 10899'tabstop' value. To be backwards compatible in indent 10900plugins, use this: >vim 10901if exists('*shiftwidth') 10902func s:sw() 10903return shiftwidth() 10904endfunc 10905else 10906func s:sw() 10907return &sw 10908endfunc 10909endif 10910<And then use s:sw() instead of &sw. 10911 10912for which to return the 'shiftwidth' value. This matters for 10913the 'vartabstop' feature. If the 'vartabstop' setting is 10914enabled and no {col} argument is given, column 1 will be 10915assumed. 10916 10917]=] , 10918name ='shiftwidth' , 10919params ={ { 'col' , 'integer' } } , 10920signature ='shiftwidth([{col}])' , 10921returns ='integer' , 10922see_lua ={ 10923"|vim.bo| for simple cases: `vim.bo.shiftwidth > 0 and vim.bo.shiftwidth or vim.bo.tabstop`; `{col}` and 'vartabstop' semantics differ" , 10924} , 10925} , 10926sign_define ={ 10927args ={ 1 , 2 } , 10928base =1 , 10929name ='sign_define' , 10930params ={ { 'name' , 'string' } , { 'dict' , 'vim.fn.sign_define.dict' } } , 10931signature ='sign_define({name} [, {dict}])' , 10932returns ='0|-1' , 10933see_lua =false , 10934} , 10935sign_define__1 ={ 10936args ={ 1 , 2 } , 10937base =1 , 10938desc =[=[ 10939Define a new sign named {name} or modify the attributes of an 10940existing sign. This is similar to the |:sign-define| command. 10941 10942Prefix {name} with a unique text to avoid name collisions. 10943There is no {group} like with placing signs. 10944 10945The {name} can be a String or a Number. The optional {dict} 10946argument specifies the sign attributes. The following values 10947are supported: 10948icon full path to the bitmap file for the sign. 10949linehl highlight group used for the whole line the 10950sign is placed in. 10951priority default priority value of the sign 10952numhl highlight group used for the line number where 10953the sign is placed. 10954text text that is displayed when there is no icon 10955or the GUI is not being used. 10956texthl highlight group used for the text item 10957culhl highlight group used for the text item when 10958the cursor is on the same line as the sign and 10959'cursorline' is enabled. 10960 10961If the sign named {name} already exists, then the attributes 10962of the sign are updated. 10963 10964The one argument {list} can be used to define a list of signs. 10965Each list item is a dictionary with the above items in {dict} 10966and a "name" item for the sign name. 10967 10968Returns 0 on success and -1 on failure. When the one argument 10969{list} is used, then returns a List of values one for each 10970defined sign. 10971 10972Examples: >vim 10973call sign_define("mySign", { 10974\ "text" : "=>", 10975\ "texthl" : "Error", 10976\ "linehl" : "Search"}) 10977call sign_define([ 10978\ {'name' : 'sign1', 10979\ 'text' : '=>'}, 10980\ {'name' : 'sign2', 10981\ 'text' : '!!'} 10982\ ]) 10983< 10984]=] , 10985name ='sign_define' , 10986params ={ { 'list' , 'vim.fn.sign_define.dict[]' } } , 10987signature ='sign_define({list})' , 10988returns ='(0|-1)[]' , 10989see_lua =false , 10990} , 10991sign_getdefined ={ 10992args ={ 0 , 1 } , 10993base =1 , 10994desc =[=[ 10995Get a list of defined signs and their attributes. 10996This is similar to the |:sign-list| command. 10997 10998If the {name} is not supplied, then a list of all the defined 10999signs is returned. Otherwise the attribute of the specified 11000sign is returned. 11001 11002Each list item in the returned value is a dictionary with the 11003following entries: 11004icon full path to the bitmap file of the sign 11005linehl highlight group used for the whole line the 11006sign is placed in; not present if not set. 11007name name of the sign 11008priority default priority value of the sign 11009numhl highlight group used for the line number where 11010the sign is placed; not present if not set. 11011text text that is displayed when there is no icon 11012or the GUI is not being used. 11013texthl highlight group used for the text item; not 11014present if not set. 11015culhl highlight group used for the text item when 11016the cursor is on the same line as the sign and 11017'cursorline' is enabled; not present if not 11018set. 11019 11020Returns an empty List if there are no signs and when {name} is 11021not found. 11022 11023Examples: >vim 11024" Get a list of all the defined signs 11025echo sign_getdefined() 11026 11027" Get the attribute of the sign named mySign 11028echo sign_getdefined("mySign") 11029< 11030]=] , 11031name ='sign_getdefined' , 11032params ={ { 'name' , 'string' } } , 11033signature ='sign_getdefined([{name}])' , 11034returns ='vim.fn.sign_getdefined.ret.item[]' , 11035see_lua =false , 11036} , 11037sign_getplaced ={ 11038args ={ 0 , 2 } , 11039base =1 , 11040desc =[=[ 11041Return a list of signs placed in a buffer or all the buffers. 11042This is similar to the |:sign-place-list| command. 11043 11044If the optional buffer name {buf} is specified, then only the 11045list of signs placed in that buffer is returned. For the use 11046of {buf}, see |bufname()|. The optional {dict} can contain 11047the following entries: 11048group select only signs in this group 11049id select sign with this identifier 11050lnum select signs placed in this line. For the use 11051of {lnum}, see |line()|. 11052If {group} is "*", then signs in all the groups including the 11053global group are returned. If {group} is not supplied or is 11054an empty string, then only signs in the global group are 11055returned. If no arguments are supplied, then signs in the 11056global group placed in all the buffers are returned. 11057See |sign-group|. 11058 11059Each list item in the returned value is a dictionary with the 11060following entries: 11061bufnr number of the buffer with the sign 11062signs list of signs placed in {bufnr}. Each list 11063item is a dictionary with the below listed 11064entries 11065 11066The dictionary for each sign contains the following entries: 11067group sign group. Set to '' for the global group. 11068id identifier of the sign 11069lnum line number where the sign is placed 11070name name of the defined sign 11071priority sign priority 11072 11073The returned signs in a buffer are ordered by their line 11074number and priority. 11075 11076Returns an empty list on failure or if there are no placed 11077signs. 11078 11079Examples: >vim 11080" Get a List of signs placed in eval.c in the 11081" global group 11082echo sign_getplaced("eval.c") 11083 11084" Get a List of signs in group 'g1' placed in eval.c 11085echo sign_getplaced("eval.c", {'group' : 'g1'}) 11086 11087" Get a List of signs placed at line 10 in eval.c 11088echo sign_getplaced("eval.c", {'lnum' : 10}) 11089 11090" Get sign with identifier 10 placed in a.py 11091echo sign_getplaced("a.py", {'id' : 10}) 11092 11093" Get sign with id 20 in group 'g1' placed in a.py 11094echo sign_getplaced("a.py", {'group' : 'g1', 11095\ 'id' : 20}) 11096 11097" Get a List of all the placed signs 11098echo sign_getplaced() 11099< 11100]=] , 11101name ='sign_getplaced' , 11102params ={ { 'buf' , 'integer|string' } , { 'dict' , 'vim.fn.sign_getplaced.dict' } } , 11103signature ='sign_getplaced([{buf} [, {dict}]])' , 11104returns ='vim.fn.sign_getplaced.ret.item[]' , 11105see_lua =false , 11106} , 11107sign_jump ={ 11108args =3 , 11109base =1 , 11110desc =[=[ 11111Open the buffer {buf} or jump to the window that contains 11112{buf} and position the cursor at sign {id} in group {group}. 11113This is similar to the |:sign-jump| command. 11114 11115If {group} is an empty string, then the global group is used. 11116For the use of {buf}, see |bufname()|. 11117 11118Returns the line number of the sign. Returns -1 if the 11119arguments are invalid. 11120 11121Example: >vim 11122" Jump to sign 10 in the current buffer 11123call sign_jump(10, '', '') 11124< 11125]=] , 11126name ='sign_jump' , 11127params ={ { 'id' , 'integer' } , { 'group' , 'string' } , { 'buf' , 'integer|string' } } , 11128signature ='sign_jump({id}, {group}, {buf})' , 11129returns ='integer' , 11130see_lua =false , 11131} , 11132sign_place ={ 11133args ={ 4 , 5 } , 11134base =1 , 11135desc =[=[ 11136Place the sign defined as {name} at line {lnum} in file or 11137buffer {buf} and assign {id} and {group} to sign. This is 11138similar to the |:sign-place| command. 11139 11140If the sign identifier {id} is zero, then a new identifier is 11141allocated. Otherwise the specified number is used. {group} 11142is the sign group name. To use the global sign group, use an 11143empty string. {group} functions as a namespace for {id}, thus 11144two groups can use the same IDs. Refer to |sign-identifier| 11145and |sign-group| for more information. 11146 11147{name} refers to a defined sign. 11148{buf} refers to a buffer name or number. For the accepted 11149values, see |bufname()|. 11150 11151The optional {dict} argument supports the following entries: 11152lnum line number in the file or buffer 11153{buf} where the sign is to be placed. 11154For the accepted values, see |line()|. 11155priority priority of the sign. See 11156|sign-priority| for more information. 11157 11158If the optional {dict} is not specified, then it modifies the 11159placed sign {id} in group {group} to use the defined sign 11160{name}. 11161 11162Returns the sign identifier on success and -1 on failure. 11163 11164Examples: >vim 11165" Place a sign named sign1 with id 5 at line 20 in 11166" buffer json.c 11167call sign_place(5, '', 'sign1', 'json.c', 11168\ {'lnum' : 20}) 11169 11170" Updates sign 5 in buffer json.c to use sign2 11171call sign_place(5, '', 'sign2', 'json.c') 11172 11173" Place a sign named sign3 at line 30 in 11174" buffer json.c with a new identifier 11175let id = sign_place(0, '', 'sign3', 'json.c', 11176\ {'lnum' : 30}) 11177 11178" Place a sign named sign4 with id 10 in group 'g3' 11179" at line 40 in buffer json.c with priority 90 11180call sign_place(10, 'g3', 'sign4', 'json.c', 11181\ {'lnum' : 40, 'priority' : 90}) 11182< 11183]=] , 11184name ='sign_place' , 11185params ={ 11186{ 'id' , 'integer' } , 11187{ 'group' , 'string' } , 11188{ 'name' , 'string' } , 11189{ 'buf' , 'integer|string' } , 11190{ 'dict' , 'vim.fn.sign_place.dict' } , 11191} , 11192signature ='sign_place({id}, {group}, {name}, {buf} [, {dict}])' , 11193returns ='integer' , 11194see_lua =false , 11195} , 11196sign_placelist ={ 11197args =1 , 11198base =1 , 11199desc =[=[ 11200Place one or more signs. This is similar to the 11201|sign_place()| function. The {list} argument specifies the 11202List of signs to place. Each list item is a dict with the 11203following sign attributes: 11204buffer Buffer name or number. For the accepted 11205values, see |bufname()|. 11206group Sign group. {group} functions as a namespace 11207for {id}, thus two groups can use the same 11208IDs. If not specified or set to an empty 11209string, then the global group is used. See 11210|sign-group| for more information. 11211id Sign identifier. If not specified or zero, 11212then a new unique identifier is allocated. 11213Otherwise the specified number is used. See 11214|sign-identifier| for more information. 11215lnum Line number in the buffer where the sign is to 11216be placed. For the accepted values, see 11217|line()|. 11218name Name of the sign to place. See |sign_define()| 11219for more information. 11220priority Priority of the sign. When multiple signs are 11221placed on a line, the sign with the highest 11222priority is used. If not specified, the 11223default value of 10 is used, unless specified 11224otherwise by the sign definition. See 11225|sign-priority| for more information. 11226 11227If {id} refers to an existing sign, then the existing sign is 11228modified to use the specified {name} and/or {priority}. 11229 11230Returns a List of sign identifiers. If failed to place a 11231sign, the corresponding list item is set to -1. 11232 11233Examples: >vim 11234" Place sign s1 with id 5 at line 20 and id 10 at line 11235" 30 in buffer a.c 11236let [n1, n2] = sign_placelist([ 11237\ {'id' : 5, 11238\ 'name' : 's1', 11239\ 'buffer' : 'a.c', 11240\ 'lnum' : 20}, 11241\ {'id' : 10, 11242\ 'name' : 's1', 11243\ 'buffer' : 'a.c', 11244\ 'lnum' : 30} 11245\ ]) 11246 11247" Place sign s1 in buffer a.c at line 40 and 50 11248" with auto-generated identifiers 11249let [n1, n2] = sign_placelist([ 11250\ {'name' : 's1', 11251\ 'buffer' : 'a.c', 11252\ 'lnum' : 40}, 11253\ {'name' : 's1', 11254\ 'buffer' : 'a.c', 11255\ 'lnum' : 50} 11256\ ]) 11257< 11258]=] , 11259name ='sign_placelist' , 11260params ={ { 'list' , 'vim.fn.sign_placelist.list.item[]' } } , 11261signature ='sign_placelist({list})' , 11262returns ='integer[]' , 11263see_lua =false , 11264} , 11265sign_undefine ={ 11266args ={ 0 , 1 } , 11267base =1 , 11268name ='sign_undefine' , 11269params ={ { 'name' , 'string' } } , 11270signature ='sign_undefine([{name}])' , 11271returns ='0|-1' , 11272see_lua =false , 11273} , 11274sign_undefine__1 ={ 11275args ={ 0 , 1 } , 11276base =1 , 11277desc =[=[ 11278Deletes a previously defined sign {name}. This is similar to 11279the |:sign-undefine| command. If {name} is not supplied, then 11280deletes all the defined signs. 11281 11282The one argument {list} can be used to undefine a list of 11283signs. Each list item is the name of a sign. 11284 11285Returns 0 on success and -1 on failure. For the one argument 11286{list} call, returns a list of values one for each undefined 11287sign. 11288 11289Examples: >vim 11290" Delete a sign named mySign 11291call sign_undefine("mySign") 11292 11293" Delete signs 'sign1' and 'sign2' 11294call sign_undefine(["sign1", "sign2"]) 11295 11296" Delete all the signs 11297call sign_undefine() 11298< 11299]=] , 11300name ='sign_undefine' , 11301params ={ { 'list' , 'string[]' } } , 11302signature ='sign_undefine({list})' , 11303returns ='integer[]' , 11304see_lua =false , 11305} , 11306sign_unplace ={ 11307args ={ 1 , 2 } , 11308base =1 , 11309desc =[=[ 11310Remove a previously placed sign in one or more buffers. This 11311is similar to the |:sign-unplace| command. 11312 11313{group} is the sign group name. To use the global sign group, 11314use an empty string. If {group} is set to "*", then all the 11315groups including the global group are used. 11316The signs in {group} are selected based on the entries in 11317{dict}. The following optional entries in {dict} are 11318supported: 11319buffer buffer name or number. See |bufname()|. 11320id sign identifier 11321If {dict} is not supplied, then all the signs in {group} are 11322removed. 11323 11324Returns 0 on success and -1 on failure. 11325 11326Examples: >vim 11327" Remove sign 10 from buffer a.vim 11328call sign_unplace('', {'buffer' : "a.vim", 'id' : 10}) 11329 11330" Remove sign 20 in group 'g1' from buffer 3 11331call sign_unplace('g1', {'buffer' : 3, 'id' : 20}) 11332 11333" Remove all the signs in group 'g2' from buffer 10 11334call sign_unplace('g2', {'buffer' : 10}) 11335 11336" Remove sign 30 in group 'g3' from all the buffers 11337call sign_unplace('g3', {'id' : 30}) 11338 11339" Remove all the signs placed in buffer 5 11340call sign_unplace('*', {'buffer' : 5}) 11341 11342" Remove the signs in group 'g4' from all the buffers 11343call sign_unplace('g4') 11344 11345" Remove sign 40 from all the buffers 11346call sign_unplace('*', {'id' : 40}) 11347 11348" Remove all the placed signs from all the buffers 11349call sign_unplace('*') 11350< 11351]=] , 11352name ='sign_unplace' , 11353params ={ { 'group' , 'string' } , { 'dict' , 'vim.fn.sign_unplace.dict' } } , 11354signature ='sign_unplace({group} [, {dict}])' , 11355returns ='0|-1' , 11356see_lua =false , 11357} , 11358sign_unplacelist ={ 11359args =1 , 11360base =1 , 11361desc =[=[ 11362Remove previously placed signs from one or more buffers. This 11363is similar to the |sign_unplace()| function. 11364 11365The {list} argument specifies the List of signs to remove. 11366Each list item is a dict with the following sign attributes: 11367buffer buffer name or number. For the accepted 11368values, see |bufname()|. If not specified, 11369then the specified sign is removed from all 11370the buffers. 11371group sign group name. If not specified or set to an 11372empty string, then the global sign group is 11373used. If set to "*", then all the groups 11374including the global group are used. 11375id sign identifier. If not specified, then all 11376the signs in the specified group are removed. 11377 11378Returns a List where an entry is set to 0 if the corresponding 11379sign was successfully removed or -1 on failure. 11380 11381Example: >vim 11382" Remove sign with id 10 from buffer a.vim and sign 11383" with id 20 from buffer b.vim 11384call sign_unplacelist([ 11385\ {'id' : 10, 'buffer' : "a.vim"}, 11386\ {'id' : 20, 'buffer' : 'b.vim'}, 11387\ ]) 11388< 11389]=] , 11390name ='sign_unplacelist' , 11391params ={ { 'list' , 'vim.fn.sign_unplacelist.list.item' } } , 11392signature ='sign_unplacelist({list})' , 11393returns ='(0|-1)[]' , 11394see_lua =false , 11395} , 11396simplify ={ 11397args =1 , 11398base =1 , 11399desc =[=[ 11400Simplify the file name as much as possible without changing 11401the meaning. Shortcuts (on MS-Windows) or symbolic links (on 11402Unix) are not resolved. If the first path component in 11403{filename} designates the current directory, this will be 11404valid for the result as well. A trailing path separator is 11405not removed either. On Unix "//path" is unchanged, but 11406"///path" is simplified to "/path" (this follows the Posix 11407standard). 11408Example: >vim 11409simplify("./dir/.././/file/") == "./file/" 11410<Note: The combination "dir/.." is only removed if "dir" is 11411a searchable directory or does not exist. On Unix, it is also 11412removed when "dir" is a symbolic link within the same 11413directory. In order to resolve all the involved symbolic 11414links before simplifying the path name, use |resolve()|. 11415 11416]=] , 11417name ='simplify' , 11418params ={ { 'filename' , 'string' } } , 11419returns ='string' , 11420signature ='simplify({filename})' , 11421see_lua ={ 11422'|vim.fs.normalize()|; `~`/$VAR expansion and leading `./` or trailing `/` handling differ' , 11423} , 11424} , 11425sin ={ 11426args =1 , 11427base =1 , 11428desc =[=[ 11429Return the sine of {expr}, measured in radians, as a |Float|. 11430{expr} must evaluate to a |Float| or a |Number|. 11431Returns 0.0 if {expr} is not a |Float| or a |Number|. 11432Examples: >vim 11433echo sin(100) 11434< -0.506366 >vim 11435echo sin(-4.01) 11436< 0.763301 11437 11438]=] , 11439func_float ='sin' , 11440name ='sin' , 11441params ={ { 'expr' , 'number' } } , 11442returns ='number' , 11443signature ='sin({expr})' , 11444see_lua ={ '|math.sin()|' } , 11445} , 11446sinh ={ 11447args =1 , 11448base =1 , 11449desc =[=[ 11450Return the hyperbolic sine of {expr} as a |Float| in the range 11451[-inf, inf]. 11452{expr} must evaluate to a |Float| or a |Number|. 11453Returns 0.0 if {expr} is not a |Float| or a |Number|. 11454Examples: >vim 11455echo sinh(0.5) 11456< 0.521095 >vim 11457echo sinh(-0.9) 11458< -1.026517 11459 11460]=] , 11461func_float ='sinh' , 11462name ='sinh' , 11463params ={ { 'expr' , 'number' } } , 11464signature ='sinh({expr})' , 11465see_lua ={ '|math.sinh()|' } , 11466} , 11467slice ={ 11468args ={ 2 , 3 } , 11469base =1 , 11470desc =[=[ 11471Similar to using a |slice| "expr[start : end]", but "end" is 11472used exclusive. And for a string the indexes are used as 11473character indexes instead of byte indexes. 11474Also, composing characters are treated as a part of the 11475preceding base character. 11476When {end} is omitted the slice continues to the last item. 11477When {end} is -1 the last item is omitted. 11478Returns an empty value if {start} or {end} are invalid. 11479 11480]=] , 11481name ='slice' , 11482params ={ { 'expr' , 'any' } , { 'start' , 'integer' } , { 'end' , 'integer' } } , 11483signature ='slice({expr}, {start} [, {end}])' , 11484} , 11485sockconnect ={ 11486args ={ 2 , 3 } , 11487desc =[=[ 11488Connect a socket to an address. If {mode} is "pipe" then 11489{address} should be the path of a local domain socket (on 11490unix) or named pipe (on Windows). If {mode} is "tcp" then 11491{address} should be of the form "host:port" where the host 11492should be an ip address or host name, and port the port 11493number. 11494 11495For "pipe" mode, see |luv-pipe-handle|. For "tcp" mode, see 11496|luv-tcp-handle|. 11497 11498Returns a |channel| ID. Close the socket with |chanclose()|. 11499Use |chansend()| to send data over a bytes socket, and 11500|rpcrequest()| and |rpcnotify()| to communicate with a RPC 11501socket. 11502 11503{opts} is an optional dictionary with these keys: 11504|on_data| : callback invoked when data was read from socket 11505data_buffered : read socket data in |channel-buffered| mode. 11506rpc : If set, |msgpack-rpc| will be used to communicate 11507over the socket. 11508Returns: 11509- The channel ID on success (greater than zero) 11510- 0 on invalid arguments or connection failure. 11511]=] , 11512name ='sockconnect' , 11513params ={ { 'mode' , 'string' } , { 'address' , 'string' } , { 'opts' , 'table' } } , 11514signature ='sockconnect({mode}, {address} [, {opts}])' , 11515} , 11516sort ={ 11517args ={ 1 , 3 } , 11518base =1 , 11519tags ={ 'E702' } , 11520desc =[=[ 11521Sort the items in {list} in-place. Returns {list}. 11522 11523If you want a list to remain unmodified make a copy first: >vim 11524let sortedlist = sort(copy(mylist)) 11525 11526<When {how} is omitted or is a string, then sort() uses the 11527string representation of each item to sort on. Numbers sort 11528after Strings, |Lists| after Numbers. For sorting text in the 11529current buffer use |:sort|. 11530 11531When {how} is given and it is 'i' then case is ignored. 11532For backwards compatibility, the value one can be used to 11533ignore case. Zero means to not ignore case. 11534 11535When {how} is given and it is 'l' then the current collation 11536locale is used for ordering. Implementation details: 11537strcoll() is used to compare strings. See |:language| to check 11538or set the collation locale. |v:collate| can also be used to 11539check the current locale. Sorting using the locale typically 11540ignores case. Example: >vim 11541" ö is sorted similarly to o with English locale. 11542language collate en_US.UTF8 11543echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l') 11544< ['n', 'o', 'O', 'ö', 'p', 'z'] ~ 11545>vim 11546" ö is sorted after z with Swedish locale. 11547language collate sv_SE.UTF8 11548echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l') 11549< ['n', 'o', 'O', 'p', 'z', 'ö'] ~ 11550This does not work properly on Mac. 11551 11552When {how} is given and it is 'n' then all items will be 11553sorted numerical (Implementation detail: this uses the 11554strtod() function to parse numbers, Strings, Lists, Dicts and 11555Funcrefs will be considered as being 0). 11556 11557When {how} is given and it is 'N' then all items will be 11558sorted numerical. This is like 'n' but a string containing 11559digits will be used as the number they represent. 11560 11561When {how} is given and it is 'f' then all items will be 11562sorted numerical. All values must be a Number or a Float. 11563 11564When {how} is a |Funcref| or a function name, this function 11565is called to compare items. The function is invoked with two 11566items as argument and must return zero if they are equal, 1 or 11567bigger if the first one sorts after the second one, -1 or 11568smaller if the first one sorts before the second one. 11569 11570{dict} is for functions with the "dict" attribute. It will be 11571used to set the local variable "self". |Dictionary-function| 11572 11573The sort is stable, items which compare equal (as number or as 11574string) will keep their relative position. E.g., when sorting 11575on numbers, text strings will sort next to each other, in the 11576same order as they were originally. 11577 11578 11579Example: >vim 11580func MyCompare(i1, i2) 11581return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1 11582endfunc 11583eval mylist->sort("MyCompare") 11584<A shorter compare version for this specific simple case, which 11585ignores overflow: >vim 11586func MyCompare(i1, i2) 11587return a:i1 - a:i2 11588endfunc 11589<For a simple expression you can use a lambda: >vim 11590eval mylist->sort({i1, i2 -> i1 - i2}) 11591< 11592]=] , 11593name ='sort' , 11594generics ={ 'T' } , 11595params ={ { 'list' , 'T[]' } , { 'how' , 'string|function' } , { 'dict' , 'any' } } , 11596returns ='T[]' , 11597signature ='sort({list} [, {how} [, {dict}]])' , 11598see_lua ={ 11599"|table.sort()| with a custom comparator; it is not stable and Vim's `i`/`l`/`n`/`N`/`f` modes differ" , 11600} , 11601} , 11602soundfold ={ 11603args =1 , 11604base =1 , 11605desc =[=[ 11606Return the sound-folded equivalent of {word}. Uses the first 11607language in 'spelllang' for the current window that supports 11608soundfolding. 'spell' must be set. When no sound folding is 11609possible the {word} is returned unmodified. 11610This can be used for making spelling suggestions. Note that 11611the method can be quite slow. 11612 11613]=] , 11614name ='soundfold' , 11615params ={ { 'word' , 'string' } } , 11616returns ='string' , 11617signature ='soundfold({word})' , 11618} , 11619spellbadword ={ 11620args ={ 0 , 1 } , 11621base =1 , 11622desc =[=[ 11623Without argument: The result is the badly spelled word under 11624or after the cursor. The cursor is moved to the start of the 11625bad word. When no bad word is found in the cursor line the 11626result is an empty string and the cursor doesn't move. 11627 11628With argument: The result is the first word in {sentence} that 11629is badly spelled. If there are no spelling mistakes the 11630result is an empty string. 11631 11632The return value is a list with two items: 11633- The badly spelled word or an empty string. 11634- The type of the spelling error: 11635"bad" spelling mistake 11636"rare" rare word 11637"local" word only valid in another region 11638"caps" word should start with Capital 11639Example: >vim 11640echo spellbadword("the quik brown fox") 11641< ['quik', 'bad'] ~ 11642 11643The spelling information for the current window and the value 11644of 'spelllang' are used. 11645 11646]=] , 11647name ='spellbadword' , 11648params ={ { 'sentence' , 'string' } } , 11649signature ='spellbadword([{sentence}])' , 11650see_lua ={ 11651'|vim.spell.check()| for string input; it returns all matches with positions, not just the first one or cursor-moving behavior' , 11652} , 11653} , 11654spellsuggest ={ 11655args ={ 1 , 3 } , 11656base =1 , 11657desc =[=[ 11658Return a |List| with spelling suggestions to replace {word}. 11659When {max} is given up to this number of suggestions are 11660returned. Otherwise up to 25 suggestions are returned. 11661 11662When the {capital} argument is given and it's non-zero only 11663suggestions with a leading capital will be given. Use this 11664after a match with 'spellcapcheck'. 11665 11666{word} can be a badly spelled word followed by other text. 11667This allows for joining two words that were split. The 11668suggestions also include the following text, thus you can 11669replace a line. 11670 11671{word} may also be a good word. Similar words will then be 11672returned. {word} itself is not included in the suggestions, 11673although it may appear capitalized. 11674 11675The spelling information for the current window is used. The 11676values of 'spelllang' and 'spellsuggest' are used. 11677 11678]=] , 11679name ='spellsuggest' , 11680params ={ { 'word' , 'string' } , { 'max' , 'integer' } , { 'capital' , 'boolean' } } , 11681returns ='string[]' , 11682signature ='spellsuggest({word} [, {max} [, {capital}]])' , 11683} , 11684split ={ 11685args ={ 1 , 3 } , 11686base =1 , 11687desc =[=[ 11688Make a |List| out of {string}. When {pattern} is omitted or 11689empty each white space separated sequence of characters 11690becomes an item. 11691Otherwise the string is split where {pattern} matches, 11692removing the matched characters. 'ignorecase' is not used 11693here, add \c to ignore case. |/\c| 11694When the first or last item is empty it is omitted, unless the 11695{keepempty} argument is given and it's non-zero. 11696Other empty items are kept when {pattern} matches at least one 11697character or when {keepempty} is non-zero. 11698Example: >vim 11699let words = split(getline('.'), '\W\+') 11700<To split a string in individual characters: >vim 11701for c in split(mystring, '\zs') | endfor 11702<If you want to keep the separator you can also use '\zs' at 11703the end of the pattern: >vim 11704echo split('abc:def:ghi', ':\zs') 11705< > 11706['abc:', 'def:', 'ghi'] 11707< 11708Splitting a table where the first element can be empty: >vim 11709let items = split(line, ':', 1) 11710<The opposite function is |join()|. 11711 11712]=] , 11713name ='split' , 11714params ={ { 'string' , 'string' } , { 'pattern' , 'string' } , { 'keepempty' , 'boolean' } } , 11715returns ='string[]' , 11716signature ='split({string} [, {pattern} [, {keepempty}]])' , 11717see_lua ={ '|vim.split()|' } , 11718} , 11719sqrt ={ 11720args =1 , 11721base =1 , 11722desc =[=[ 11723Return the non-negative square root of Float {expr} as a 11724|Float|. 11725{expr} must evaluate to a |Float| or a |Number|. When {expr} 11726is negative the result is NaN (Not a Number). Returns 0.0 if 11727{expr} is not a |Float| or a |Number|. 11728Examples: >vim 11729echo sqrt(100) 11730< 10.0 >vim 11731echo sqrt(-4.01) 11732< str2float("nan") 11733NaN may be different, it depends on system libraries. 11734 11735]=] , 11736func_float ='sqrt' , 11737name ='sqrt' , 11738params ={ { 'expr' , 'number' } } , 11739signature ='sqrt({expr})' , 11740see_lua ={ '|math.sqrt()|' } , 11741} , 11742srand ={ 11743args ={ 0 , 1 } , 11744base =1 , 11745desc =[=[ 11746Initialize seed used by |rand()|: 11747- If {expr} is not given, seed values are initialized by 11748reading from /dev/urandom, if possible, or using time(NULL) 11749a.k.a. epoch time otherwise; this only has second accuracy. 11750- If {expr} is given it must be a Number. It is used to 11751initialize the seed values. This is useful for testing or 11752when a predictable sequence is intended. 11753 11754Examples: >vim 11755let seed = srand() 11756let seed = srand(userinput) 11757echo rand(seed) 11758< 11759]=] , 11760name ='srand' , 11761params ={ { 'expr' , 'number' } } , 11762signature ='srand([{expr}])' , 11763see_lua ={ '|math.randomseed()|' } , 11764} , 11765state ={ 11766args ={ 0 , 1 } , 11767base =1 , 11768desc =[=[ 11769Return a string which contains characters indicating the 11770current state. Mostly useful in callbacks that want to do 11771work that may not always be safe. Roughly this works like: 11772- callback uses state() to check if work is safe to do. 11773Yes: then do it right away. 11774No: add to work queue and add a |SafeState| autocommand. 11775- When SafeState is triggered and executes your autocommand, 11776check with `state()` if the work can be done now, and if yes 11777remove it from the queue and execute. 11778Remove the autocommand if the queue is now empty. 11779Also see |mode()|. 11780 11781When {what} is given only characters in this string will be 11782added. E.g, this checks if the screen has scrolled: >vim 11783if state('s') == '' 11784" screen has not scrolled 11785< 11786These characters indicate the state, generally indicating that 11787something is busy: 11788m halfway a mapping, :normal command, |feedkeys()| or 11789stuffed command 11790o operator pending, e.g. after |d| 11791a Insert mode autocomplete active 11792x executing an autocommand 11793S not triggering SafeState, e.g. after |f| or a count 11794c callback invoked, including timer (repeats for 11795recursiveness up to "ccc") 11796s screen has scrolled for messages 11797]=] , 11798fast =true , 11799name ='state' , 11800params ={ { 'what' , 'string' } } , 11801signature ='state([{what}])' , 11802} , 11803stdioopen ={ 11804args =1 , 11805desc =[=[ 11806With |--headless| this opens stdin and stdout as a |channel|. 11807May be called only once. See |channel-stdio|. stderr is not 11808handled by this function, see |v:stderr|. 11809 11810Close the stdio handles with |chanclose()|. Use |chansend()| 11811to send data to stdout, and |rpcrequest()| and |rpcnotify()| 11812to communicate over RPC. 11813 11814{opts} is a dictionary with these keys: 11815|on_stdin| : callback invoked when stdin is written to. 11816on_print : callback invoked when Nvim needs to print a 11817message, with the message (whose type is string) 11818as sole argument. 11819stdin_buffered : read stdin in |channel-buffered| mode. 11820rpc : If set, |msgpack-rpc| will be used to communicate 11821over stdio 11822Returns: 11823- |channel-id| on success (value is always 1) 11824- 0 on invalid arguments 11825]=] , 11826name ='stdioopen' , 11827params ={ { 'opts' , 'table' } } , 11828signature ='stdioopen({opts})' , 11829} , 11830stdpath ={ 11831args =1 , 11832tags ={ 'E6100' } , 11833desc =[=[ 11834Returns |standard-path| locations of various default files and 11835directories. The locations are driven by |base-directories| 11836which you can configure via |$NVIM_APPNAME| or the `$XDG_…` 11837environment variables. 11838 11839{what} Type Description ~ 11840cache String Cache directory: arbitrary temporary 11841storage for plugins, etc. 11842config String User configuration directory. |init.vim| 11843is stored here. 11844config_dirs List Other configuration directories. 11845data String User data directory. 11846data_dirs List Other data directories. 11847log String Logs directory (for use by plugins too). 11848run String Run directory: temporary, local storage 11849for sockets, named pipes, etc. 11850state String Session state: storage for backupdir, 11851file drafts, |shada|, swap, undo, 'viewdir'. 11852 11853Example: >vim 11854echo stdpath("config") 11855< 11856]=] , 11857fast =true , 11858name ='stdpath' , 11859params ={ { 'what' , "'cache'|'config'|'config_dirs'|'data'|'data_dirs'|'log'|'run'|'state'" } } , 11860returns ='string|string[]' , 11861signature ='stdpath({what})' , 11862} , 11863stdpath__1 ={ 11864args =1 , 11865fast =true , 11866name ='stdpath' , 11867params ={ { 'what' , "'cache'|'config'|'data'|'log'|'run'|'state'" } } , 11868returns ='string' , 11869} , 11870stdpath__2 ={ 11871args =1 , 11872fast =true , 11873name ='stdpath' , 11874params ={ { 'what' , "'config_dirs'|'data_dirs'" } } , 11875returns ='string[]' , 11876} , 11877str2float ={ 11878args =1 , 11879base =1 , 11880desc =[=[ 11881Convert String {string} to a Float. This mostly works the 11882same as when using a floating point number in an expression, 11883see |floating-point-format|. But it's a bit more permissive. 11884E.g., "1e40" is accepted, while in an expression you need to 11885write "1.0e40". The hexadecimal form "0x123" is also 11886accepted, but not others, like binary or octal. 11887When {quoted} is present and non-zero then embedded single 11888quotes before the dot are ignored, thus "1'000.0" is a 11889thousand. 11890Text after the number is silently ignored. 11891The decimal point is always '.', no matter what the locale is 11892set to. A comma ends the number: "12,345.67" is converted to 1189312.0. You can strip out thousands separators with 11894|substitute()|: >vim 11895let f = str2float(substitute(text, ',', '', 'g')) 11896< 11897Returns 0.0 if the conversion fails. 11898 11899]=] , 11900name ='str2float' , 11901params ={ { 'string' , 'string' } , { 'quoted' , 'boolean' } } , 11902signature ='str2float({string} [, {quoted}])' , 11903see_lua ={ 11904'|tonumber()| for simple numbers; quoted digits, hex forms, and trailing text differ' , 11905} , 11906} , 11907str2list ={ 11908args ={ 1 , 2 } , 11909base =1 , 11910desc =[=[ 11911Return a list containing the number values which represent 11912each character in String {string}. Examples: >vim 11913echo str2list(" ") " returns [32] 11914echo str2list("ABC") " returns [65, 66, 67] 11915<|list2str()| does the opposite. 11916 11917UTF-8 encoding is always used, {utf8} option has no effect, 11918and exists only for backwards-compatibility. 11919With UTF-8 composing characters are handled properly: >vim 11920echo str2list("á") " returns [97, 769] 11921< 11922]=] , 11923fast =true , 11924name ='str2list' , 11925params ={ { 'string' , 'string' } , { 'utf8' , 'boolean' } } , 11926signature ='str2list({string} [, {utf8}])' , 11927} , 11928str2nr ={ 11929args ={ 1 , 3 } , 11930base =1 , 11931desc =[=[ 11932Convert string {string} to a number. 11933{base} is the conversion base, it can be 2, 8, 10 or 16. 11934When {quoted} is present and non-zero then embedded single 11935quotes are ignored, thus "1'000'000" is a million. 11936 11937When {base} is omitted base 10 is used. This also means that 11938a leading zero doesn't cause octal conversion to be used, as 11939with the default String to Number conversion. Example: >vim 11940let nr = str2nr('0123') 11941< 11942When {base} is 16 a leading "0x" or "0X" is ignored. With a 11943different base the result will be zero. Similarly, when 11944{base} is 8 a leading "0", "0o" or "0O" is ignored, and when 11945{base} is 2 a leading "0b" or "0B" is ignored. 11946Text after the number is silently ignored. 11947 11948Returns 0 if {string} is empty or on error. 11949 11950]=] , 11951name ='str2nr' , 11952params ={ { 'string' , 'string' } , { 'base' , 'integer' } } , 11953signature ='str2nr({string} [, {base}])' , 11954see_lua ={ 11955'|tonumber()| for simple numbers; quoted digits, base prefixes, and trailing text differ' , 11956} , 11957} , 11958strcharlen ={ 11959args =1 , 11960base =1 , 11961desc =[=[ 11962Returns the number of characters in String {string}, ignoring 11963composing characters. Returns 0 on error or empty {string}. 11964 11965|strchars()| can count the number of characters, counting 11966composing characters separately. 11967 11968Also see |strlen()|, |strdisplaywidth()| and |strwidth()|. 11969 11970]=] , 11971fast =true , 11972name ='strcharlen' , 11973params ={ { 'string' , 'string' } } , 11974returns ='integer' , 11975signature ='strcharlen({string})' , 11976} , 11977strcharpart ={ 11978args ={ 2 , 4 } , 11979base =1 , 11980desc =[=[ 11981Like |strpart()| but using character index and length instead 11982of byte index and length. 11983When {skipcc} is omitted or zero, composing characters are 11984counted separately. 11985When {skipcc} set to 1, composing characters are treated as a 11986part of the preceding base character, similar to |slice()|. 11987When a character index is used where a character does not 11988exist it is omitted and counted as one character. For 11989example: >vim 11990echo strcharpart('abc', -1, 2) 11991<results in 'a'. 11992 11993Returns an empty string on error. 11994 11995]=] , 11996fast =true , 11997name ='strcharpart' , 11998params ={ 11999{ 'src' , 'string' } , 12000{ 'start' , 'integer' } , 12001{ 'len' , 'integer' } , 12002{ 'skipcc' , '0|1|boolean' } , 12003} , 12004returns ='string' , 12005signature ='strcharpart({src}, {start} [, {len} [, {skipcc}]])' , 12006} , 12007strchars ={ 12008args ={ 1 , 2 } , 12009base =1 , 12010desc =[=[ 12011Returns the number of characters in String {string}. 12012When {skipcc} is omitted or zero, composing characters are 12013counted separately. 12014When {skipcc} set to 1, composing characters are ignored. 12015|strcharlen()| always does this. 12016 12017Returns zero on error. 12018 12019Also see |strlen()|, |strdisplaywidth()| and |strwidth()|. 12020 12021{skipcc} is only available after 7.4.755. For backward 12022compatibility, you can define a wrapper function: >vim 12023if has("patch-7.4.755") 12024function s:strchars(str, skipcc) 12025return strchars(a:str, a:skipcc) 12026endfunction 12027else 12028function s:strchars(str, skipcc) 12029if a:skipcc 12030return strlen(substitute(a:str, ".", "x", "g")) 12031else 12032return strchars(a:str) 12033endif 12034endfunction 12035endif 12036< 12037]=] , 12038fast =true , 12039name ='strchars' , 12040params ={ { 'string' , 'string' } , { 'skipcc' , '0|1|boolean' } } , 12041returns ='integer' , 12042signature ='strchars({string} [, {skipcc}])' , 12043see_lua ={ '|vim.str_utfindex()| for codepoint counts; `skipcc` handling differs' } , 12044} , 12045strdisplaywidth ={ 12046args ={ 1 , 2 } , 12047base =1 , 12048desc =[=[ 12049Returns the number of display cells String {string} occupies 12050on the screen when it starts at {col} (first column is zero). 12051Returns zero on error. 12052 12053When {col} is omitted zero is used. Otherwise it is the screen 12054column where to start. This matters for Tab characters. 12055The option settings of the current window are used. This 12056matters for anything that's displayed differently, such as 12057'tabstop' and 'display'. 12058 12059When {string} contains characters with East Asian Width Class 12060Ambiguous, this function's return value depends on 12061'ambiwidth'. 12062 12063Also see |strlen()|, |strwidth()| and |strchars()|. 12064 12065]=] , 12066fast =true , 12067name ='strdisplaywidth' , 12068params ={ { 'string' , 'string' } , { 'col' , 'integer' } } , 12069returns ='integer' , 12070signature ='strdisplaywidth({string} [, {col}])' , 12071see_lua ={ 12072'|nvim_strwidth()| when `{col}` is 0; Tab expansion and window-option semantics differ' , 12073} , 12074} , 12075strftime ={ 12076args ={ 1 , 2 } , 12077base =1 , 12078desc =[=[ 12079Formats a date and time String specified by {format}. The 12080given {time} is used, or the current time if no time is given. 12081The {format} depends on your system, this is not portable! 12082See the manual page of the C function strftime() for the 12083format. The maximum length of the result is 80 characters. 12084See also |localtime()|, |getftime()| and |strptime()|. 12085The language can be changed with the |:language| command. 12086Examples: >vim 12087echo strftime("%c") " Sun Apr 27 11:49:23 1997 12088echo strftime("%Y %b %d %X") " 1997 Apr 27 11:53:25 12089echo strftime("%y%m%d %T") " 970427 11:53:55 12090echo strftime("%H:%M") " 11:55 12091echo strftime("%c", getftime("file.c")) 12092" Show mod time of file.c. 12093< 12094]=] , 12095name ='strftime' , 12096params ={ { 'format' , 'string' } , { 'time' , 'number' } } , 12097returns ='string' , 12098signature ='strftime({format} [, {time}])' , 12099see_lua ={ '|os.date()|' } , 12100} , 12101strgetchar ={ 12102args =2 , 12103base =1 , 12104desc =[=[ 12105Get a Number corresponding to the character at {index} in 12106{str}. This uses a zero-based character index, not a byte 12107index. Composing characters are considered separate 12108characters here. Use |nr2char()| to convert the Number to a 12109String. 12110Returns -1 if {index} is invalid. 12111Also see |strcharpart()| and |strchars()|. 12112 12113]=] , 12114fast =true , 12115name ='strgetchar' , 12116params ={ { 'str' , 'string' } , { 'index' , 'integer' } } , 12117returns ='integer' , 12118signature ='strgetchar({str}, {index})' , 12119} , 12120stridx ={ 12121args ={ 2 , 3 } , 12122base =1 , 12123desc =[=[ 12124Returns the byte index of the first occurrence of {needle} 12125in {haystack}. 12126If {start} is specified, the search starts at index {start}. 12127This can be used to find a second match: >vim 12128let colon1 = stridx(line, ":") 12129let colon2 = stridx(line, ":", colon1 + 1) 12130<The search is done case-sensitive. 12131For pattern searches use |match()|. 12132-1 is returned if the {needle} does not occur in {haystack}. 12133See also |strridx()|. 12134Examples: >vim 12135echo stridx("An Example", "Example") " 3 12136echo stridx("Starting point", "Start") " 0 12137echo stridx("Starting point", "start") " -1 12138< *strstr()* *strchr()* 12139stridx() works similar to the C function strstr(). When used 12140with a single character it works similar to strchr(). 12141 12142]=] , 12143fast =true , 12144name ='stridx' , 12145params ={ { 'haystack' , 'string' } , { 'needle' , 'string' } , { 'start' , 'integer' } } , 12146returns ='integer' , 12147signature ='stridx({haystack}, {needle} [, {start}])' , 12148see_lua ={ 12149'|string.find()| with `plain = true` and `start + 1`, then subtract 1; missing matches return nil instead of -1' , 12150} , 12151} , 12152string ={ 12153args =1 , 12154base =1 , 12155desc =[=[ 12156Converts {expr} to a String. If {expr} is a Number, Float, 12157String, Blob or a composition of them, the result can be 12158parsed back with |eval()|. 12159 12160{expr} type result ~ 12161String `'string'` 12162Number 123 12163Float 123.123456 or 1.123456e8 or 12164`str2float('inf')` 12165Funcref `function('name')` 12166Blob 0z00112233.44556677.8899 12167List [item, item] 12168Dictionary `{key: value, key: value}` 12169 12170Note: in String values the ' character is doubled. 12171Also see |strtrans()|. 12172 12173Note: Output format is mostly compatible with YAML, except for 12174infinite and NaN floating-point values representations which 12175use |str2float()|. Strings are also dumped literally, only 12176single quote is escaped, which does not allow using YAML for 12177parsing back binary strings. |eval()| should always work for 12178strings and floats though, and this is the only official 12179method. Use |msgpackdump()| or |json_encode()| if you need to 12180share data with other applications. 12181 12182]=] , 12183name ='string' , 12184params ={ { 'expr' , 'any' } } , 12185returns ='string' , 12186signature ='string({expr})' , 12187see_lua ={ '|vim.inspect()| for tables, or |tostring()| for scalars' } , 12188} , 12189strlen ={ 12190args =1 , 12191base =1 , 12192desc =[=[ 12193Returns the length of String {string} in bytes. 12194If the argument is a Number it is first converted to a String. 12195For other types an error is given and zero is returned. 12196If you want to count the number of multibyte characters use 12197|strchars()|. 12198Also see |len()|, |strdisplaywidth()| and |strwidth()|. 12199 12200]=] , 12201fast =true , 12202name ='strlen' , 12203params ={ { 'string' , 'string' } } , 12204returns ='integer' , 12205signature ='strlen({string})' , 12206see_lua ={ '|string.len()|' } , 12207} , 12208strpart ={ 12209args ={ 2 , 4 } , 12210base =1 , 12211desc =[=[ 12212Gets a substring from {src}, starting from byte {start}, with 12213byte length {len}. Returns empty string on error. 12214 12215When {chars} is present and TRUE then {len} is the number of 12216characters positions (composing characters are not counted 12217separately, thus "1" means one base character and any 12218following composing characters). 12219 12220To count {start} as characters instead of bytes use 12221|strcharpart()|. 12222 12223When bytes are selected which do not exist, this doesn't 12224result in an error, the bytes are simply omitted. 12225If {len} is missing, the copy continues from {start} till the 12226end of the {src}. >vim 12227echo strpart("abcdefg", 3, 2) " returns 'de' 12228echo strpart("abcdefg", -2, 4) " returns 'ab' 12229echo strpart("abcdefg", 5, 4) " returns 'fg' 12230echo strpart("abcdefg", 3) " returns 'defg' 12231 12232<Note: To get the first character, {start} must be 0. For 12233example, to get the character under the cursor: >vim 12234strpart(getline("."), col(".") - 1, 1, v:true) 12235< 12236 12237]=] , 12238fast =true , 12239name ='strpart' , 12240params ={ 12241{ 'src' , 'string' } , 12242{ 'start' , 'integer' } , 12243{ 'len' , 'integer' } , 12244{ 'chars' , '0|1' } , 12245} , 12246returns ='string' , 12247signature ='strpart({src}, {start} [, {len} [, {chars}]])' , 12248see_lua ={ '|string.sub()| for byte slices; negative `start` and the `chars` flag differ' } , 12249} , 12250strptime ={ 12251args =2 , 12252base =1 , 12253desc =[=[ 12254Parses a date/time string and returns a unix timestamp. 12255{timestring} must match the format specified in {format}. 12256 12257The {format} depends on your system, this is not portable! 12258See the strptime() manpage for the format. Especially avoid 12259"%c". The value of $TZ also matters. 12260 12261If the {timestring} cannot be parsed with {format} zero is 12262returned. If you do not know the format of {timestring} you 12263can try different {format} values until you get a non-zero 12264result. 12265 12266See also |strftime()|. 12267Examples: >vim 12268echo strptime("%Y %b %d %X", "1997 Apr 27 11:49:23") 12269< 862156163 >vim 12270echo strftime("%c", strptime("%y%m%d %T", "970427 11:53:55")) 12271< Sun Apr 27 11:53:55 1997 >vim 12272echo strftime("%c", strptime("%Y%m%d%H%M%S", "19970427115355") + 3600) 12273< Sun Apr 27 12:53:55 1997 12274 12275]=] , 12276name ='strptime' , 12277params ={ { 'format' , 'string' } , { 'timestring' , 'string' } } , 12278returns ='integer' , 12279signature ='strptime({format}, {timestring})' , 12280} , 12281strridx ={ 12282args ={ 2 , 3 } , 12283base =1 , 12284desc =[=[ 12285Returns the byte index of the last occurrence of {needle} 12286in {haystack}. 12287When {start} is specified, matches beyond this index are 12288ignored. This can be used to find a match before a previous 12289match: >vim 12290let lastcomma = strridx(line, ",") 12291let comma2 = strridx(line, ",", lastcomma - 1) 12292<The search is done case-sensitive. 12293For pattern searches use |match()|. 12294-1 is returned if the {needle} does not occur in {haystack}. 12295If the {needle} is empty the length of {haystack} is returned. 12296See also |stridx()|. Examples: >vim 12297echo strridx("an angry armadillo", "an") 3 12298< *strrchr()* 12299When used with a single character it works similar to the C 12300function strrchr(). 12301 12302]=] , 12303name ='strridx' , 12304params ={ 12305{ 'haystack' , 'string' } , 12306{ 'needle' , 'string' } , 12307{ 'start' , 'integer' } , 12308} , 12309returns ='integer' , 12310signature ='strridx({haystack}, {needle} [, {start}])' , 12311see_lua ={ 12312'|string.find()| in a loop with `plain = true`, then subtract 1; empty-needle and missing-match semantics differ' , 12313} , 12314} , 12315strtrans ={ 12316args =1 , 12317base =1 , 12318desc =[=[ 12319Translates all unprintable characters in {string} into 12320printable characters, like they are shown in a 12321window. Example: >vim 12322echo strtrans(@a) 12323<This displays a newline in register a as "^@" instead of 12324starting a new line. 12325 12326Returns an empty string on error. 12327 12328]=] , 12329fast =true , 12330name ='strtrans' , 12331params ={ { 'string' , 'string' } } , 12332returns ='string' , 12333signature ='strtrans({string})' , 12334} , 12335strutf16len ={ 12336args ={ 1 , 2 } , 12337base =1 , 12338desc =[=[ 12339Returns the number of UTF-16 code units in String {string} 12340(after converting it to UTF-16). 12341 12342When {countcc} is TRUE, composing characters are counted 12343separately. 12344When {countcc} is omitted or FALSE, composing characters are 12345ignored. 12346 12347Returns zero on error. 12348 12349Also see |strlen()| and |strcharlen()|. 12350Examples: >vim 12351echo strutf16len('a') " returns 1 12352echo strutf16len('©') " returns 1 12353echo strutf16len('😊') " returns 2 12354echo strutf16len('ą́') " returns 1 12355echo strutf16len('ą́', v:true) " returns 3 12356< 12357]=] , 12358name ='strutf16len' , 12359params ={ { 'string' , 'string' } , { 'countcc' , '0|1' } } , 12360returns ='integer' , 12361signature ='strutf16len({string} [, {countcc}])' , 12362see_lua ={ '|vim.str_utfindex()| with `"utf-16"`; `countcc = false` semantics differ' } , 12363} , 12364strwidth ={ 12365args =1 , 12366base =1 , 12367desc =[=[ 12368Returns the number of display cells String {string} occupies. 12369A Tab character is counted as one cell, alternatively use 12370|strdisplaywidth()|. 12371When {string} contains characters with East Asian Width Class 12372Ambiguous, this function's return value depends on 12373'ambiwidth'. 12374Returns zero on error. 12375Also see |strlen()|, |strdisplaywidth()| and |strchars()|. 12376 12377]=] , 12378fast =true , 12379name ='strwidth' , 12380params ={ { 'string' , 'string' } } , 12381returns ='integer' , 12382signature ='strwidth({string})' , 12383see_lua ={ '|nvim_strwidth()|' } , 12384} , 12385submatch ={ 12386args ={ 1 , 2 } , 12387base =1 , 12388tags ={ 'E935' } , 12389desc =[=[ 12390Only for an expression in a |:substitute| command or 12391|substitute()| function. 12392Returns the {nr}th submatch of the matched text. When {nr} 12393is 0 the whole matched text is returned. 12394Note that a NL in the string can stand for a line break of a 12395multi-line match or a NUL character in the text. 12396Also see |sub-replace-expression|. 12397 12398If {list} is present and non-zero then submatch() returns 12399a list of strings, similar to |getline()| with two arguments. 12400NL characters in the text represent NUL characters in the 12401text. 12402Only returns more than one item for |:substitute|, inside 12403|substitute()| this list will always contain one or zero 12404items, since there are no real line breaks. 12405 12406When |substitute()| is used recursively only the submatches in 12407the current (deepest) call can be obtained. 12408 12409Returns an empty string or list on error. 12410 12411Examples: >vim 12412s/\d\+/\=submatch(0) + 1/ 12413echo substitute(text, '\d\+', '\=submatch(0) + 1', '') 12414<This finds the first number in the line and adds one to it. 12415A line break is included as a newline character. 12416 12417]=] , 12418name ='submatch' , 12419params ={ { 'nr' , 'integer' } , { 'list' , 'nil' } } , 12420signature ='submatch({nr} [, {list}])' , 12421returns ='string' , 12422} , 12423submatch__1 ={ 12424args ={ 2 } , 12425base =1 , 12426name ='submatch' , 12427params ={ { 'nr' , 'integer' } , { 'list' , 'integer' } } , 12428returns ='string|string[]' , 12429} , 12430substitute ={ 12431args =4 , 12432base =1 , 12433desc =[=[ 12434Performs string substitution. Returns a copy of {string} 12435in which the first match of {pat} is replaced with {sub}. 12436When {flags} is "g", all matches of {pat} in {string} are 12437replaced. Otherwise {flags} should be "". 12438 12439This works like the ":substitute" command (without any flags). 12440But the matching with {pat} is always done like the 'magic' 12441option is set and 'cpoptions' is empty (to make scripts 12442portable). 'ignorecase' is still relevant, use |/\c| or |/\C| 12443if you want to ignore or match case and ignore 'ignorecase'. 12444'smartcase' is not used. See |string-match| for how {pat} is 12445used. 12446 12447A "~" in {sub} is not replaced with the previous {sub}. 12448Note that some codes in {sub} have a special meaning 12449|sub-replace-special|. For example, to replace something with 12450"\n" (two characters), use "\\\\n" or '\\n'. 12451 12452When {pat} does not match in {string}, {string} is returned 12453unmodified. 12454 12455Example: >vim 12456let &path = substitute(&path, ",\\=[^,]*$", "", "") 12457<This removes the last component of the 'path' option. >vim 12458echo substitute("testing", ".*", "\\U\\0", "") 12459<results in "TESTING". 12460 12461When {sub} starts with "\=", the remainder is interpreted as 12462an expression. See |sub-replace-expression|. Example: >vim 12463echo substitute(s, '%\(\x\x\)', 12464\ '\=nr2char("0x" .. submatch(1))', 'g') 12465 12466<When {sub} is a Funcref that function is called, with one 12467optional argument. Example: >vim 12468echo substitute(s, '%\(\x\x\)', SubNr, 'g') 12469<The optional argument is a list which contains the whole 12470matched string and up to nine submatches, like what 12471|submatch()| returns. Example: >vim 12472echo substitute(s, '%\(\x\x\)', {m -> '0x' .. m[1]}, 'g') 12473 12474<Returns an empty string on error. 12475 12476]=] , 12477name ='substitute' , 12478params ={ 12479{ 'string' , 'string' } , 12480{ 'pat' , 'string' } , 12481{ 'sub' , 'string' } , 12482{ 'flags' , 'string' } , 12483} , 12484returns ='string' , 12485signature ='substitute({string}, {pat}, {sub}, {flags})' , 12486see_lua ={ 12487'|string.gsub()| for common substitutions; Vim patterns, flags, and replacement semantics differ' , 12488} , 12489} , 12490swapfilelist ={ 12491desc =[=[ 12492Returns a list of swap file names, like what "vim -r" shows. 12493See the |-r| command argument. The 'directory' option is used 12494for the directories to inspect. If you only want to get a 12495list of swap files in the current directory then temporarily 12496set 'directory' to a dot: >vim 12497let save_dir = &directory 12498let &directory = '.' 12499let swapfiles = swapfilelist() 12500let &directory = save_dir 12501< 12502]=] , 12503name ='swapfilelist' , 12504params ={} , 12505returns ='string[]' , 12506signature ='swapfilelist()' , 12507} , 12508swapinfo ={ 12509args =1 , 12510base =1 , 12511desc =[=[ 12512Returns information about the swapfile {fname} as a 12513dictionary. The available fields are: 12514version Vim version 12515user user name 12516host host name 12517fname original file name 12518pid PID of the Nvim process that created the swap 12519file, or zero if not running. 12520mtime last modification time in seconds 12521inode Optional: INODE number of the file 12522dirty 1 if file was modified, 0 if not 12523In case of failure an "error" item is added with the reason: 12524Cannot open file: file not found or in accessible 12525Cannot read file: cannot read first block 12526Not a swap file: does not contain correct block ID 12527Magic number mismatch: Info in first block is invalid 12528 12529]=] , 12530name ='swapinfo' , 12531params ={ { 'fname' , 'string' } } , 12532signature ='swapinfo({fname})' , 12533} , 12534swapname ={ 12535args =1 , 12536base =1 , 12537desc =[=[ 12538The result is the swap file path of the buffer {buf}. 12539For the use of {buf}, see |bufname()| above. 12540If buffer {buf} is the current buffer, the result is equal to 12541|:swapname| (unless there is no swap file). 12542If buffer {buf} has no swap file, returns an empty string. 12543 12544]=] , 12545name ='swapname' , 12546params ={ { 'buf' , 'integer|string' } } , 12547returns ='string' , 12548signature ='swapname({buf})' , 12549} , 12550synID ={ 12551args =3 , 12552desc =[=[ 12553Returns the syntax ID at position {lnum} and {col} in the 12554current window. The syntax ID can be used with |synIDattr()| 12555and |synIDtrans()| to obtain syntax information about text. 12556 12557{col} is 1 for the leftmost column, {lnum} is 1 for the first 12558line. 'synmaxcol' applies, in a longer line zero is returned. 12559Note that when the position is after the last character, 12560that's where the cursor can be in Insert mode, synID() returns 12561zero. {lnum} is used like with |getline()|. 12562 12563When {trans} is |TRUE|, transparent items are reduced to the 12564item that they reveal. This is useful when wanting to know 12565the effective color. When {trans} is |FALSE|, the transparent 12566item is returned. This is useful when wanting to know which 12567syntax item is effective (e.g. inside parens). 12568Warning: This function can be very slow. Best speed is 12569obtained by going through the file in forward direction. 12570 12571Returns zero on error. 12572 12573Example (echoes the name of the syntax item under the cursor): >vim 12574echo synIDattr(synID(line("."), col("."), 1), "name") 12575< 12576]=] , 12577name ='synID' , 12578params ={ { 'lnum' , 'integer|string' } , { 'col' , 'integer' } , { 'trans' , '0|1' } } , 12579returns ='integer' , 12580signature ='synID({lnum}, {col}, {trans})' , 12581} , 12582synIDattr ={ 12583args ={ 2 , 3 } , 12584base =1 , 12585desc =[=[ 12586Returns the {what} attribute of syntax ID {synID} as a 12587String. This can be used to obtain information about a 12588syntax item. 12589{mode} can be "gui" or "cterm", to get the attributes 12590for that mode. When {mode} is omitted, or an invalid value is 12591used, the attributes for the currently active highlighting are 12592used (GUI or cterm). 12593Use |synIDtrans()| to follow linked highlight groups. 12594{what} result 12595"name" the name of the syntax item 12596"fg" foreground color (GUI: color name used to set 12597the color, cterm: color number as a string, 12598term: empty string) 12599"bg" background color (as with "fg") 12600"font" font name (only available in the GUI) 12601|highlight-font| 12602"sp" special color (as with "fg") |guisp| 12603"fg#" like "fg", but for the GUI and the GUI is 12604running the name in "#RRGGBB" form 12605"bg#" like "fg#" for "bg" 12606"sp#" like "fg#" for "sp" 12607"bold" "1" if bold 12608"italic" "1" if italic 12609"reverse" "1" if reverse 12610"inverse" "1" if inverse (= reverse) 12611"standout" "1" if standout 12612"underline" "1" if underlined 12613"undercurl" "1" if undercurled 12614"underdouble" "1" if double underlined 12615"underdotted" "1" if dotted underlined 12616"underdashed" "1" if dashed underlined 12617"strikethrough" "1" if struckthrough 12618"altfont" "1" if alternative font 12619"nocombine" "1" if nocombine 12620"dim" "1" if half-bright/dimmed 12621"blink" "1" if blinking 12622"conceal" "1" if concealed 12623"overline" "1" if overlined 12624 12625Returns an empty string on error. 12626 12627Example (echoes the color of the syntax item under the 12628cursor): >vim 12629echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg") 12630< 12631Can also be used as a |method|: >vim 12632echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg") 12633< 12634]=] , 12635name ='synIDattr' , 12636params ={ { 'synID' , 'integer' } , { 'what' , 'string' } , { 'mode' , 'string' } } , 12637returns ='string' , 12638signature ='synIDattr({synID}, {what} [, {mode}])' , 12639} , 12640synIDtrans ={ 12641args =1 , 12642base =1 , 12643desc =[=[ 12644Returns the translated syntax ID of {synID}, following 12645highlight links. This is the syntax group ID of what is 12646being used to highlight the character. Highlight links given with 12647":highlight link" are followed. 12648 12649Returns zero on error. 12650 12651]=] , 12652name ='synIDtrans' , 12653params ={ { 'synID' , 'integer' } } , 12654returns ='integer' , 12655signature ='synIDtrans({synID})' , 12656} , 12657synconcealed ={ 12658args =2 , 12659desc =[=[ 12660Returns conceal information for the character at position 12661{lnum} and {col} as a |List| with three items: 126621. The first item in the list is 0 if the character is not 12663part of a concealable region, 1 if it is. {lnum} is used 12664like with |getline()|. 126652. The second item in the list is a string. If the first item 12666is 1, the second item contains the text which will be 12667displayed in place of the concealed text, depending on the 12668current setting of 'conceallevel' and 'listchars'. 126693. The third and final item in the list is a number 12670representing the specific syntax region matched in the 12671line. When the character is not concealed the value is 12672zero. This allows detection of the beginning of a new 12673concealable region if there are two consecutive regions 12674with the same replacement character. For an example, if 12675the text is "123456" and both "23" and "45" are concealed 12676and replaced by the character "X", then: 12677call returns ~ 12678synconcealed(lnum, 1) [0, '', 0] 12679synconcealed(lnum, 2) [1, 'X', 1] 12680synconcealed(lnum, 3) [1, 'X', 1] 12681synconcealed(lnum, 4) [1, 'X', 2] 12682synconcealed(lnum, 5) [1, 'X', 2] 12683synconcealed(lnum, 6) [0, '', 0] 12684 12685Note: Doesn't consider |matchadd()| highlighting items, 12686since syntax and matching highlighting are two different 12687mechanisms |syntax-vs-match|. 12688]=] , 12689name ='synconcealed' , 12690params ={ { 'lnum' , 'integer|string' } , { 'col' , 'integer' } } , 12691returns ='[integer, string, integer]' , 12692signature ='synconcealed({lnum}, {col})' , 12693} , 12694synstack ={ 12695args =2 , 12696desc =[=[ 12697Return a |List|, which is the stack of syntax items at the 12698position {lnum} and {col} in the current window. {lnum} is 12699used like with |getline()|. Each item in the List is an ID 12700like what |synID()| returns. 12701The first item in the List is the outer region, following are 12702items contained in that one. The last one is what |synID()| 12703returns, unless not the whole item is highlighted or it is a 12704transparent item. 12705This function is useful for debugging a syntax file. 12706Example that shows the syntax stack under the cursor: >vim 12707for id in synstack(line("."), col(".")) 12708echo synIDattr(id, "name") 12709endfor 12710<When the position specified with {lnum} and {col} is invalid 12711an empty list is returned. The position just after the last 12712character in a line and the first column in an empty line are 12713valid positions. 12714]=] , 12715name ='synstack' , 12716params ={ { 'lnum' , 'integer|string' } , { 'col' , 'integer' } } , 12717returns ='integer[]' , 12718signature ='synstack({lnum}, {col})' , 12719} , 12720system ={ 12721args ={ 1 , 2 } , 12722base =1 , 12723tags ={ 'E677' } , 12724desc =[=[ 12725Gets the output of {cmd} as a |string| (|systemlist()| returns 12726a |List|) and sets |v:shell_error| to the error code. 12727{cmd} is treated as in |jobstart()|: 12728If {cmd} is a List it runs directly (no 'shell'). 12729If {cmd} is a String it runs in the 'shell', like this: >vim 12730call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}']) 12731 12732<Not to be used for interactive commands. 12733 12734Result is a String, filtered to avoid platform-specific quirks: 12735- <CR><NL> is replaced with <NL> 12736- NUL characters are replaced with SOH (0x01) 12737 12738Example: >vim 12739echo system(['ls', expand('%:h')]) 12740 12741<If {input} is a string it is written to a pipe and passed as 12742stdin to the command. The string is written as-is, line 12743separators are not changed. 12744If {input} is a |List| it is written to the pipe as 12745|writefile()| does with {binary} set to "b" (i.e. with 12746a newline between each list item, and newlines inside list 12747items converted to NULs). 12748When {input} is given and is a valid buffer id, the content of 12749the buffer is written to the file line by line, each line 12750terminated by NL (and NUL where the text has NL). 12751*E5677* 12752Note: system() cannot write to or read from backgrounded ("&") 12753shell commands, e.g.: >vim 12754echo system("cat - &", "foo") 12755<which is equivalent to: > 12756$ echo foo | bash -c 'cat - &' 12757<The pipes are disconnected (unless overridden by shell 12758redirection syntax) before input can reach it. Use 12759|jobstart()| instead. 12760 12761Note: Use |shellescape()| or |::S| with |expand()| or 12762|fnamemodify()| to escape special characters in a command 12763argument. 'shellquote' and 'shellxquote' must be properly 12764configured. Example: >vim 12765echo system('ls '..shellescape(expand('%:h'))) 12766echo system('ls '..expand('%:h:S')) 12767 12768<Unlike ":!cmd" there is no automatic check for changed files. 12769Use |:checktime| to force a check. 12770 12771]=] , 12772name ='system' , 12773params ={ 12774{ 'cmd' , 'string|string[]' } , 12775{ 'input' , 'string|string[]|integer' } , 12776} , 12777returns ='string' , 12778signature ='system({cmd} [, {input}])' , 12779see_lua ={ 12780'`vim.system(...):wait().stdout` for string output; string commands use the shell in Vimscript, not by default in Lua' , 12781} , 12782} , 12783systemlist ={ 12784args ={ 1 , 3 } , 12785base =1 , 12786desc =[=[ 12787Same as |system()|, but returns a |List| with lines (parts of 12788output separated by NL) with NULs transformed into NLs. 12789Output is the same as |readfile()| will output with {binary} 12790argument set to "b", except that a final newline is not 12791preserved, unless {keepempty} is non-zero. 12792Note that on MS-Windows you may get trailing CR characters. 12793 12794To see the difference between "echo hello" and "echo -n hello" 12795use |system()| and |split()|: >vim 12796echo split(system('echo hello'), '\n', 1) 12797< 12798Returns an empty string on error. 12799 12800]=] , 12801name ='systemlist' , 12802params ={ 12803{ 'cmd' , 'string|string[]' } , 12804{ 'input' , 'string|string[]|integer' } , 12805{ 'keepempty' , 'integer' } , 12806} , 12807-- TODO(lewis6991): Not sure the '' return case is possible via vim.fn 12808-- returns = "string[]|''", 12809returns ='string[]' , 12810signature ='systemlist({cmd} [, {input} [, {keepempty}]])' , 12811see_lua ={ 12812'`vim.system(...):wait().stdout` split into lines; string commands use the shell in Vimscript, not by default in Lua' , 12813} , 12814} , 12815tabpagebuflist ={ 12816args ={ 0 , 1 } , 12817base =1 , 12818desc =[=[ 12819Returns a |List| of buffer numbers, one for each window in 12820the specified tabpage. 12821{arg} specifies the number of the tabpage to be used. When 12822omitted the current tabpage is used. 12823When {arg} is invalid the number zero is returned. 12824To get a list of all buffers in all tabs use this: >vim 12825let buflist = [] 12826for i in range(tabpagenr('$')) 12827call extend(buflist, tabpagebuflist(i + 1)) 12828endfor 12829<Note that a buffer may appear in more than one window. 12830 12831]=] , 12832name ='tabpagebuflist' , 12833params ={ { 'arg' , 'integer' } } , 12834signature ='tabpagebuflist([{arg}])' , 12835see_lua ={ 12836'|nvim_tabpage_list_wins()| with |nvim_win_get_buf()|; invalid tabpages error instead of returning 0' , 12837} , 12838} , 12839tabpagenr ={ 12840args ={ 0 , 1 } , 12841desc =[=[ 12842Returns the current |tabpage-number|. 12843 12844The optional argument {arg} supports the following values: 12845$ the last |tabpage-number| (the tabpage count). 12846# the last-accessed |tabpage-number| (where |g<Tab>| 12847goes to), or 0 if there is no previous tabpage. 12848The number can be used with the |:tab| command. 12849 12850Returns zero on error. 12851]=] , 12852name ='tabpagenr' , 12853params ={ { 'arg' , "'$'|'#'" } } , 12854returns ='integer' , 12855signature ='tabpagenr([{arg}])' , 12856see_lua ={ 12857'|nvim_tabpage_get_number()| with |nvim_get_current_tabpage()| for the current tab, or `#vim.api.nvim_list_tabpages()` for "$"; "#" differs' , 12858} , 12859} , 12860tabpagewinnr ={ 12861args ={ 1 , 2 } , 12862base =1 , 12863desc =[=[ 12864Like |winnr()| but for tabpage {tabarg}. 12865{tabarg} specifies the |tabpage-number| to be used. 12866{arg} is used like with |winnr()|: 12867- When omitted the current window number is returned. This is 12868the window which will be used when going to this tabpage. 12869- When "$" the number of windows is returned. 12870- When "#" the previous window nr is returned. 12871Useful examples: >vim 12872tabpagewinnr(1) " current window of tabpage 1 12873tabpagewinnr(4, '$') " number of windows in tabpage 4 12874<When {tabarg} is invalid zero is returned. 12875 12876]=] , 12877name ='tabpagewinnr' , 12878params ={ { 'tabarg' , 'integer' } , { 'arg' , "'$'|'#'" } } , 12879returns ='integer' , 12880signature ='tabpagewinnr({tabarg} [, {arg}])' , 12881see_lua ={ 12882'|nvim_win_get_number()| with |nvim_tabpage_get_win()| for the current window, or the length of |nvim_tabpage_list_wins()| for "$"; "#" and invalid-tab behavior differ' , 12883} , 12884} , 12885tagfiles ={ 12886desc =[=[ 12887Returns a |List| with the file names used to search for tags 12888for the current buffer. This is the 'tags' option expanded. 12889]=] , 12890name ='tagfiles' , 12891params ={} , 12892returns ='string[]' , 12893signature ='tagfiles()' , 12894} , 12895taglist ={ 12896args ={ 1 , 2 } , 12897base =1 , 12898desc =[=[ 12899Returns a |List| of tags matching the regular expression {expr}. 12900 12901If {filename} is passed it is used to prioritize the results 12902in the same way that |:tselect| does. See |tag-priority|. 12903{filename} should be the full path of the file. 12904 12905Each list item is a dictionary with at least the following 12906entries: 12907name Name of the tag. 12908filename Name of the file where the tag is 12909defined. It is either relative to the 12910current directory or a full path. 12911cmd Ex command used to locate the tag in 12912the file. 12913kind Type of the tag. The value for this 12914entry depends on the language specific 12915kind values. Only available when 12916using a tags file generated by 12917Universal/Exuberant ctags or hdrtag. 12918static A file specific tag. Refer to 12919|static-tag| for more information. 12920More entries may be present, depending on the content of the 12921tags file: access, implementation, inherits and signature. 12922Refer to the ctags documentation for information about these 12923fields. For C code the fields "struct", "class" and "enum" 12924may appear, they give the name of the entity the tag is 12925contained in. 12926 12927The ex-command "cmd" can be either an ex search pattern, a 12928line number or a line number followed by a byte number. 12929 12930If there are no matching tags, then an empty list is returned. 12931 12932To get an exact tag match, the anchors '^' and '$' should be 12933used in {expr}. This also make the function work faster. 12934Refer to |tag-regexp| for more information about the tag 12935search regular expression pattern. 12936 12937Refer to 'tags' for information about how the tags file is 12938located by Vim. Refer to |tags-file-format| for the format of 12939the tags file generated by the different ctags tools. 12940 12941]=] , 12942name ='taglist' , 12943params ={ { 'expr' , 'any' } , { 'filename' , 'string' } } , 12944signature ='taglist({expr} [, {filename}])' , 12945} , 12946tan ={ 12947args =1 , 12948base =1 , 12949desc =[=[ 12950Return the tangent of {expr}, measured in radians, as a |Float| 12951in the range [-inf, inf]. 12952{expr} must evaluate to a |Float| or a |Number|. 12953Returns 0.0 if {expr} is not a |Float| or a |Number|. 12954Examples: >vim 12955echo tan(10) 12956< 0.648361 >vim 12957echo tan(-4.01) 12958< -1.181502 12959 12960]=] , 12961func_float ='tan' , 12962name ='tan' , 12963params ={ { 'expr' , 'number' } } , 12964returns ='number' , 12965signature ='tan({expr})' , 12966see_lua ={ '|math.tan()|' } , 12967} , 12968tanh ={ 12969args =1 , 12970base =1 , 12971desc =[=[ 12972Return the hyperbolic tangent of {expr} as a |Float| in the 12973range [-1, 1]. 12974{expr} must evaluate to a |Float| or a |Number|. 12975Returns 0.0 if {expr} is not a |Float| or a |Number|. 12976Examples: >vim 12977echo tanh(0.5) 12978< 0.462117 >vim 12979echo tanh(-1) 12980< -0.761594 12981 12982]=] , 12983func_float ='tanh' , 12984name ='tanh' , 12985params ={ { 'expr' , 'number' } } , 12986returns ='number' , 12987signature ='tanh({expr})' , 12988see_lua ={ '|math.tanh()|' } , 12989} , 12990tempname ={ 12991desc =[=[ 12992Generates a (non-existent) filename located in the Nvim root 12993|tempdir|. Scripts can use the filename as a temporary file. 12994Example: >vim 12995let tmpfile = tempname() 12996exe "redir > " .. tmpfile 12997< 12998]=] , 12999name ='tempname' , 13000params ={} , 13001returns ='string' , 13002signature ='tempname()' , 13003see_lua ={ 13004"|os.tmpname()| for a temporary name; Nvim's |tempdir| and nonexistence are not guaranteed" , 13005} , 13006} , 13007termopen ={ 13008deprecated =true , 13009args ={ 1 , 2 } , 13010desc =[=[ 13011Use |jobstart()| with `{term: v:true}` instead. 13012]=] , 13013name ='termopen' , 13014params ={ { 'cmd' , 'string|string[]' } , { 'opts' , 'table' } } , 13015returns ='integer' , 13016signature ='termopen({cmd} [, {opts}])' , 13017} , 13018test_garbagecollect_now ={ 13019args =0 , 13020desc =[=[ 13021Like |garbagecollect()|, but executed right away. This must 13022only be called directly to avoid any structure to exist 13023internally, and |v:testing| must have been set before calling 13024any function. *E1142* 13025]=] , 13026params ={} , 13027signature ='test_garbagecollect_now()' , 13028lua =false , 13029} , 13030test_write_list_log ={ 13031args =1 , 13032params ={ { 'fname' , 'string' } } , 13033lua =false , 13034} , 13035timer_info ={ 13036args ={ 0 , 1 } , 13037base =1 , 13038desc =[=[ 13039Return a list with information about timers. 13040When {id} is given only information about this timer is 13041returned. When timer {id} does not exist an empty list is 13042returned. 13043When {id} is omitted information about all timers is returned. 13044 13045For each timer the information is stored in a |Dictionary| with 13046these items: 13047"id" the timer ID 13048"time" time the timer was started with 13049"repeat" number of times the timer will still fire; 13050-1 means forever 13051"callback" the callback 13052 13053]=] , 13054name ='timer_info' , 13055params ={ { 'id' , 'integer' } } , 13056signature ='timer_info([{id}])' , 13057} , 13058timer_pause ={ 13059args =2 , 13060base =1 , 13061desc =[=[ 13062Pause or unpause a timer. A paused timer does not invoke its 13063callback when its time expires. Unpausing a timer may cause 13064the callback to be invoked almost immediately if enough time 13065has passed. 13066 13067Pausing a timer is useful to avoid the callback to be called 13068for a short time. 13069 13070If {paused} evaluates to a non-zero Number or a non-empty 13071String, then the timer is paused, otherwise it is unpaused. 13072See |non-zero-arg|. 13073 13074]=] , 13075name ='timer_pause' , 13076params ={ { 'timer' , 'integer' } , { 'paused' , 'boolean' } } , 13077signature ='timer_pause({timer}, {paused})' , 13078} , 13079timer_start ={ 13080args ={ 2 , 3 } , 13081base =1 , 13082tags ={ 'timer' } , 13083desc =[=[ 13084Create a timer and return the timer ID. 13085 13086{time} is the waiting time in milliseconds. This is the 13087minimum time before invoking the callback. When the system is 13088busy or Vim is not waiting for input the time will be longer. 13089Zero can be used to execute the callback when Vim is back in 13090the main loop. 13091 13092{callback} is the function to call. It can be the name of a 13093function or a |Funcref|. It is called with one argument, which 13094is the timer ID. The callback is only invoked when Vim is 13095waiting for input. 13096 13097{options} is a dictionary. Supported entries: 13098"repeat" Number of times to repeat the callback. 13099-1 means forever. Default is 1. 13100If the timer causes an error three times in a 13101row the repeat is cancelled. 13102 13103Returns -1 on error. 13104 13105Example: >vim 13106func MyHandler(timer) 13107echo 'Handler called' 13108endfunc 13109let timer = timer_start(500, 'MyHandler', 13110\ {'repeat': 3}) 13111<This invokes MyHandler() three times at 500 msec intervals. 13112 13113]=] , 13114name ='timer_start' , 13115params ={ { 'time' , 'number' } , { 'callback' , 'string|function' } , { 'options' , 'table' } } , 13116signature ='timer_start({time}, {callback} [, {options}])' , 13117see_lua ={ 13118'|vim.defer_fn()| for one-shot timers, or |uv.new_timer()| for repeating timers; callback and handle semantics differ' , 13119} , 13120} , 13121timer_stop ={ 13122args =1 , 13123base =1 , 13124desc =[=[ 13125Stop a timer. The timer callback will no longer be invoked. 13126{timer} is an ID returned by |timer_start()|, thus it must be a 13127Number. If {timer} does not exist there is no error. 13128 13129]=] , 13130name ='timer_stop' , 13131params ={ { 'timer' , 'integer' } } , 13132signature ='timer_stop({timer})' , 13133see_lua ={ 13134'|uv.timer_stop()| and |uv.close()| on a stored |uv.new_timer()| handle; timer IDs differ' , 13135} , 13136} , 13137timer_stopall ={ 13138args =0 , 13139desc =[=[ 13140Stop all timers. The timer callbacks will no longer be 13141invoked. Useful if some timers is misbehaving. If there are 13142no timers there is no error. 13143]=] , 13144name ='timer_stopall' , 13145params ={} , 13146signature ='timer_stopall()' , 13147} , 13148tolower ={ 13149args =1 , 13150base =1 , 13151desc =[=[ 13152Converts a String to lowercase (like applying |gu|). 13153Returns empty string on error. 13154 13155]=] , 13156fast =true , 13157name ='tolower' , 13158params ={ { 'expr' , 'string' } } , 13159returns ='string' , 13160signature ='tolower({expr})' , 13161see_lua ={ '|string.lower()|' } , 13162} , 13163toupper ={ 13164args =1 , 13165base =1 , 13166desc =[=[ 13167Converts a String to uppercase (like applying |gU|). 13168Returns empty string on error. 13169 13170]=] , 13171fast =true , 13172name ='toupper' , 13173params ={ { 'expr' , 'string' } } , 13174returns ='string' , 13175signature ='toupper({expr})' , 13176see_lua ={ '|string.upper()|' } , 13177} , 13178tr ={ 13179args =3 , 13180base =1 , 13181desc =[=[ 13182Translates characters in {src}, replacing each character that 13183appears in {fromstr} with the corresponding character in 13184{tostr}. Exactly like the unix "tr" command. 13185This code also deals with multibyte characters properly. 13186 13187Returns an empty string on error. 13188 13189Examples: >vim 13190echo tr("hello there", "ht", "HT") 13191<returns "Hello THere" >vim 13192echo tr("<blob>", "<>", "{}") 13193<returns "{blob}" 13194 13195]=] , 13196fast =true , 13197name ='tr' , 13198params ={ { 'src' , 'string' } , { 'fromstr' , 'string' } , { 'tostr' , 'string' } } , 13199returns ='string' , 13200signature ='tr({src}, {fromstr}, {tostr})' , 13201} , 13202trim ={ 13203args ={ 1 , 3 } , 13204base =1 , 13205desc =[=[ 13206Return {text} as a String where any character in {mask} is 13207removed from the beginning and/or end of {text}. 13208 13209If {mask} is not given, or is an empty string, {mask} is all 13210characters up to 0x20, which includes Tab, space, NL and CR, 13211plus the non-breaking space character 0xa0. 13212 13213The optional {dir} argument specifies where to remove the 13214characters: 132150 remove from the beginning and end of {text} 132161 remove only at the beginning of {text} 132172 remove only at the end of {text} 13218When omitted both ends are trimmed. 13219 13220This function deals with multibyte characters properly. 13221Returns an empty string on error. 13222 13223Examples: >vim 13224echo trim(" some text ") 13225<returns "some text" >vim 13226echo trim(" \r\t\t\r RESERVE \t\n\x0B\xA0") .. "_TAIL" 13227<returns "RESERVE_TAIL" >vim 13228echo trim("rm<Xrm<>X>rrm", "rm<>") 13229<returns "Xrm<>X" (characters in the middle are not removed) >vim 13230echo trim(" vim ", " ", 2) 13231<returns " vim" 13232 13233]=] , 13234fast =true , 13235name ='trim' , 13236params ={ { 'text' , 'string' } , { 'mask' , 'string' } , { 'dir' , '0|1|2' } } , 13237returns ='string' , 13238signature ='trim({text} [, {mask} [, {dir}]])' , 13239see_lua ={ '|vim.trim()|' } , 13240} , 13241trunc ={ 13242args =1 , 13243base =1 , 13244desc =[=[ 13245Return the largest integral value with magnitude less than or 13246equal to {expr} as a |Float| (truncate towards zero). 13247{expr} must evaluate to a |Float| or a |Number|. 13248Returns 0.0 if {expr} is not a |Float| or a |Number|. 13249Examples: >vim 13250echo trunc(1.456) 13251< 1.0 >vim 13252echo trunc(-5.456) 13253< -5.0 >vim 13254echo trunc(4.0) 13255< 4.0 13256 13257]=] , 13258func_float ='trunc' , 13259name ='trunc' , 13260params ={ { 'expr' , 'number' } } , 13261returns ='integer' , 13262signature ='trunc({expr})' , 13263see_lua ={ '|math.modf()| (first return value)' } , 13264} , 13265type ={ 13266args =1 , 13267base =1 , 13268desc =[=[ 13269Returns the type of {expr} as a Number. 13270Instead of using the number directly, it is better to use the 13271v:t_ variable that has the value: 13272Number: 0 |v:t_number| 13273String: 1 |v:t_string| 13274Funcref: 2 |v:t_func| 13275List: 3 |v:t_list| 13276Dictionary: 4 |v:t_dict| 13277Float: 5 |v:t_float| 13278Boolean: 6 |v:t_bool| (|v:false| and |v:true|) 13279Null: 7 (|v:null|) 13280Blob: 10 |v:t_blob| 13281For backward compatibility, this method can be used: >vim 13282if type(myvar) == type(0) | endif 13283if type(myvar) == type("") | endif 13284if type(myvar) == type(function("tr")) | endif 13285if type(myvar) == type([]) | endif 13286if type(myvar) == type({}) | endif 13287if type(myvar) == type(0.0) | endif 13288if type(myvar) == type(v:true) | endif 13289<In place of checking for |v:null| type it is better to check 13290for |v:null| directly as it is the only value of this type: >vim 13291if myvar is v:null | endif 13292<To check if the v:t_ variables exist use this: >vim 13293if exists('v:t_number') | endif 13294< 13295 13296]=] , 13297fast =true , 13298name ='type' , 13299params ={ { 'expr' , 'any' } } , 13300returns ='integer' , 13301signature ='type({expr})' , 13302see_lua ={ '|lua-type()| for most Lua type checks; Vim type IDs differ' } , 13303} , 13304undofile ={ 13305args =1 , 13306base =1 , 13307desc =[=[ 13308Return the name of the undo file that would be used for a file 13309with name {name} when writing. This uses the 'undodir' 13310option, finding directories that exist. It does not check if 13311the undo file exists. 13312{name} is always expanded to the full path, since that is what 13313is used internally. 13314If {name} is empty undofile() returns an empty string, since a 13315buffer without a file name will not write an undo file. 13316Useful in combination with |:wundo| and |:rundo|. 13317 13318]=] , 13319name ='undofile' , 13320params ={ { 'name' , 'string' } } , 13321returns ='string' , 13322signature ='undofile({name})' , 13323} , 13324undotree ={ 13325args ={ 0 , 1 } , 13326base =1 , 13327desc =[=[ 13328Return the current state of the undo tree for the current 13329buffer, or for a specific buffer if {buf} is given. The 13330result is a dictionary with the following items: 13331"seq_last" The highest undo sequence number used. 13332"seq_cur" The sequence number of the current position in 13333the undo tree. This differs from "seq_last" 13334when some changes were undone. 13335"time_cur" Time last used for |:earlier| and related 13336commands. Use |strftime()| to convert to 13337something readable. 13338"save_last" Number of the last file write. Zero when no 13339write yet. 13340"save_cur" Number of the current position in the undo 13341tree. 13342"synced" Non-zero when the last undo block was synced. 13343This happens when waiting from input from the 13344user. See |undo-blocks|. 13345"entries" A list of dictionaries with information about 13346undo blocks. 13347 13348The first item in the "entries" list is the oldest undo item. 13349Each List item is a |Dictionary| with these items: 13350"seq" Undo sequence number. Same as what appears in 13351|:undolist|. 13352"time" Timestamp when the change happened. Use 13353|strftime()| to convert to something readable. 13354"newhead" Only appears in the item that is the last one 13355that was added. This marks the last change 13356and where further changes will be added. 13357"curhead" Only appears in the item that is the last one 13358that was undone. This marks the current 13359position in the undo tree, the block that will 13360be used by a redo command. When nothing was 13361undone after the last change this item will 13362not appear anywhere. 13363"save" Only appears on the last block before a file 13364write. The number is the write count. The 13365first write has number 1, the last one the 13366"save_last" mentioned above. 13367"alt" Alternate entry. This is again a List of undo 13368blocks. Each item may again have an "alt" 13369item. 13370]=] , 13371name ='undotree' , 13372params ={ { 'buf' , 'integer|string' } } , 13373returns ='vim.fn.undotree.ret' , 13374signature ='undotree([{buf}])' , 13375} , 13376uniq ={ 13377args ={ 1 , 3 } , 13378base =1 , 13379tags ={ 'E882' } , 13380desc =[=[ 13381Remove second and succeeding copies of repeated adjacent 13382{list} items in-place. Returns {list}. If you want a list 13383to remain unmodified make a copy first: >vim 13384let newlist = uniq(copy(mylist)) 13385<The default compare function uses the string representation of 13386each item. For the use of {func} and {dict} see |sort()|. 13387For deduplicating text in the current buffer see |:uniq|. 13388 13389Returns zero if {list} is not a |List|. 13390 13391]=] , 13392name ='uniq' , 13393params ={ { 'list' , 'any' } , { 'func' , 'any' } , { 'dict' , 'any' } } , 13394returns ='any[]|0' , 13395signature ='uniq({list} [, {func} [, {dict}]])' , 13396see_lua ={ '|vim.list.unique()|' } , 13397} , 13398utf16idx ={ 13399args ={ 2 , 4 } , 13400base =1 , 13401desc =[=[ 13402Same as |charidx()| but returns the UTF-16 code unit index of 13403the byte at {idx} in {string} (after converting it to UTF-16). 13404 13405When {charidx} is present and TRUE, {idx} is used as the 13406character index in the String {string} instead of as the byte 13407index. 13408An {idx} in the middle of a UTF-8 sequence is rounded 13409downwards to the beginning of that sequence. 13410 13411Returns -1 if the arguments are invalid or if there are less 13412than {idx} bytes in {string}. If there are exactly {idx} 13413bytes, the length of the string in UTF-16 code units is 13414returned. 13415 13416See |byteidx()| and |byteidxcomp()| for getting the byte index 13417from the UTF-16 index and |charidx()| for getting the 13418character index from the UTF-16 index. 13419Refer to |string-offset-encoding| for more information. 13420Examples: >vim 13421echo utf16idx('a😊😊', 3) " returns 2 13422echo utf16idx('a😊😊', 7) " returns 4 13423echo utf16idx('a😊😊', 1, 0, 1) " returns 2 13424echo utf16idx('a😊😊', 2, 0, 1) " returns 4 13425echo utf16idx('aą́c', 6) " returns 2 13426echo utf16idx('aą́c', 6, 1) " returns 4 13427echo utf16idx('a😊😊', 9) " returns -1 13428< 13429]=] , 13430fast =true , 13431name ='utf16idx' , 13432params ={ 13433{ 'string' , 'string' } , 13434{ 'idx' , 'integer' } , 13435{ 'countcc' , 'boolean' } , 13436{ 'charidx' , 'boolean' } , 13437} , 13438returns ='integer' , 13439signature ='utf16idx({string}, {idx} [, {countcc} [, {charidx}]])' , 13440see_lua ={ 13441'|vim.str_utfindex()| with `"utf-16"` and `strict_indexing = false`; `countcc` and `charidx` semantics differ' , 13442} , 13443} , 13444values ={ 13445args =1 , 13446base =1 , 13447desc =[=[ 13448Return a |List| with all the values of {dict}. The |List| is 13449in arbitrary order. Also see |items()| and |keys()|. 13450Returns zero if {dict} is not a |Dict|. 13451 13452]=] , 13453name ='values' , 13454params ={ { 'dict' , 'any' } } , 13455signature ='values({dict})' , 13456see_lua ={ '|vim.tbl_values()|' } , 13457} , 13458virtcol ={ 13459args ={ 1 , 3 } , 13460base =1 , 13461desc =[=[ 13462Returns the virtual (screen) column of the file position 13463given with {expr}. That is, the total number of screen cells 13464occupied by the part of the line until the end of the 13465character at that position. When there is a <Tab> at the 13466position, the returned Number will be the column at the end of 13467the <Tab>. For example, for a <Tab> in column 1, with 'ts' 13468set to 8, it returns 8. |conceal| is ignored. 13469For the byte position use |col()|. 13470 13471For the use of {expr} see |getpos()| and |col()|. 13472When {expr} is "$", it means the end of the cursor line, so 13473the result is the number of cells in the cursor line plus one. 13474 13475When 'virtualedit' is used {expr} can be [lnum, col, off], 13476where "off" is the offset in screen columns from the start of 13477the character. E.g., a position within a <Tab> or after the 13478last character. When "off" is omitted zero is used. When 13479Virtual editing is active in the current mode, a position 13480beyond the end of the line can be returned. Also see 13481'virtualedit' 13482 13483If {list} is present and non-zero then virtcol() returns a 13484List with the first and last screen position occupied by the 13485character. 13486 13487With the optional {winid} argument the values are obtained for 13488that window instead of the current window. 13489 13490Note that only marks in the current file can be used. 13491Examples: >vim 13492" With text "foo^Lbar" and cursor on the "^L": 13493 13494echo virtcol(".") " returns 5 13495echo virtcol(".", 1) " returns [4, 5] 13496echo virtcol("$") " returns 9 13497 13498" With text " there", with 't at 'h': 13499 13500echo virtcol("'t") " returns 6 13501< 13502The first column is 1. 0 or [0, 0] is returned for an error. 13503 13504A more advanced example that echoes the maximum length of 13505all lines: >vim 13506echo max(map(range(1, line('$')), "virtcol([v:val, '$'])")) 13507< 13508 13509]=] , 13510name ='virtcol' , 13511params ={ { 'expr' , 'string|any[]' } , { 'list' , 'boolean' } , { 'winid' , 'integer' } } , 13512returns ='integer|[integer, integer]' , 13513signature ='virtcol({expr} [, {list} [, {winid}]])' , 13514} , 13515virtcol2col ={ 13516args =3 , 13517base =1 , 13518desc =[=[ 13519Converts a virtual column to a byte index. Returns the byte 13520index of the character in window {winid} at buffer line 13521{lnum} and virtual column {col}. 13522 13523If buffer line {lnum} is an empty line, 0 is returned. 13524 13525If {col} is greater than the last virtual column in line 13526{lnum}, then the byte index of the character at the last 13527virtual column is returned. 13528 13529For a multi-byte character, the column number of the first 13530byte in the character is returned. 13531 13532{winid} is a |window-number| or |window-ID|. If zero, the 13533current window is used. 13534 13535Returns -1 if the window {winid} doesn't exist or the buffer 13536line {lnum} or virtual column {col} is invalid. 13537 13538See also |screenpos()|, |virtcol()| and |col()|. 13539 13540]=] , 13541name ='virtcol2col' , 13542params ={ { 'winid' , 'integer' } , { 'lnum' , 'integer' } , { 'col' , 'integer' } } , 13543returns ='integer' , 13544signature ='virtcol2col({winid}, {lnum}, {col})' , 13545} , 13546visualmode ={ 13547args ={ 0 , 1 } , 13548desc =[=[ 13549Returns a String describing the last Visual mode used in the 13550current buffer. Initially it returns an empty string, but 13551once Visual mode has been used, it returns "v", 13552"V", or "<CTRL-V>" (a single CTRL-V character) for 13553character-wise, line-wise, or block-wise Visual mode 13554respectively. 13555Example: >vim 13556exe "normal " .. visualmode() 13557<This enters the same Visual mode as before. It is also useful 13558in scripts if you wish to act differently depending on the 13559Visual mode that was used. 13560If Visual mode is active, use |mode()| to get the Visual mode 13561(e.g., in a |:vmap|). 13562If {expr} is supplied and it evaluates to a non-zero Number or 13563a non-empty String, then the Visual mode will be cleared and 13564the old value is returned. See |non-zero-arg|. 13565]=] , 13566name ='visualmode' , 13567params ={ { 'expr' , 'boolean' } } , 13568returns ='string' , 13569signature ='visualmode([{expr}])' , 13570} , 13571wait ={ 13572args ={ 2 , 3 } , 13573desc =[=[ 13574Waits until {condition} evaluates to |TRUE|, where {condition} 13575is a |Funcref| or |string| containing an expression. 13576 13577{timeout} is the maximum waiting time in milliseconds, -1 13578means forever. 13579 13580Condition is evaluated on user events, internal events, and 13581every {interval} milliseconds (default: 200). 13582 13583Returns a status integer: 135840 if the condition was satisfied before timeout 13585-1 if the timeout was exceeded 13586-2 if the function was interrupted (by |CTRL-C|) 13587-3 if an error occurred 13588]=] , 13589name ='wait' , 13590params ={ { 'timeout' , 'integer' } , { 'condition' , 'any' } , { 'interval' , 'number' } } , 13591signature ='wait({timeout}, {condition} [, {interval}])' , 13592see_lua ={ '|vim.wait()|' } , 13593} , 13594wildmenumode ={ 13595desc =[=[ 13596Returns |TRUE| when the wildmenu is active and |FALSE| 13597otherwise. See 'wildmenu' and 'wildmode'. 13598This can be used in mappings to handle the 'wildcharm' option 13599gracefully. (Makes only sense with |mapmode-c| mappings). 13600 13601For example to make <c-j> work like <down> in wildmode, use: >vim 13602cnoremap <expr> <C-j> wildmenumode() ? "\<Down>\<Tab>" : "\<c-j>" 13603< 13604(Note: this needs the 'wildcharm' option set appropriately). 13605]=] , 13606name ='wildmenumode' , 13607params ={} , 13608signature ='wildmenumode()' , 13609} , 13610wildtrigger ={ 13611desc =[==[ 13612Start wildcard expansion in the command-line, using the 13613behavior defined by the 'wildmode' and 'wildoptions' settings. 13614 13615This function also enables completion in search patterns such 13616as |/|, |?|, |:s|, |:g|, |:v| and |:vimgrep|. 13617 13618Unlike pressing 'wildchar' manually, this function does not 13619produce a beep when no matches are found and generally 13620operates more quietly. This makes it suitable for triggering 13621completion automatically. 13622 13623Note: After navigating command-line history, the first call to 13624wildtrigger() is a no-op; a second call is needed to start 13625expansion. This is to support history navigation in 13626command-line autocompletion. 13627 13628See |cmdline-autocompletion|. 13629 13630Return value is always 0. 13631]==] , 13632name ='wildtrigger' , 13633params ={} , 13634returns ='number' , 13635signature ='wildtrigger()' , 13636} , 13637win_execute ={ 13638args ={ 2 , 3 } , 13639base =2 , 13640desc =[=[ 13641Like `execute()` but in the context of window {id}. 13642The window will temporarily be made the current window, 13643without triggering autocommands or changing directory. When 13644executing {command} autocommands will be triggered, this may 13645have unexpected side effects. Use `:noautocmd` if needed. 13646Example: >vim 13647call win_execute(winid, 'syntax enable') 13648<Doing the same with `setwinvar()` would not trigger 13649autocommands and not actually show syntax highlighting. 13650 13651When window {id} does not exist then no error is given and 13652an empty string is returned. 13653 13654]=] , 13655name ='win_execute' , 13656params ={ { 'id' , 'integer' } , { 'command' , 'string' } , { 'silent' , 'boolean' } } , 13657signature ='win_execute({id}, {command} [, {silent}])' , 13658see_lua ={ '|nvim_win_call()|' } , 13659} , 13660win_findbuf ={ 13661args =1 , 13662base =1 , 13663desc =[=[ 13664Returns a |List| with |window-ID|s for windows that contain 13665buffer {bufnr}. When there is none the list is empty. 13666 13667]=] , 13668name ='win_findbuf' , 13669params ={ { 'bufnr' , 'integer' } } , 13670returns ='integer[]' , 13671signature ='win_findbuf({bufnr})' , 13672see_lua ={ '|nvim_list_wins()| with |nvim_win_get_buf()|' } , 13673} , 13674win_getid ={ 13675args ={ 0 , 2 } , 13676base =1 , 13677desc =[=[ 13678Get the |window-ID| for the specified window. 13679When {win} is missing use the current window. 13680With {win} this is the |window-number|. 13681Without {tab} use the current tab, otherwise the 13682|tabpage-number| given by {tab}. 13683Return zero if the window cannot be found. 13684 13685]=] , 13686name ='win_getid' , 13687params ={ { 'win' , 'integer' } , { 'tab' , 'integer' } } , 13688returns ='integer' , 13689signature ='win_getid([{win} [, {tab}]])' , 13690see_lua ={ 13691'|nvim_get_current_win()| when omitted, or |nvim_tabpage_list_wins()| with |nvim_win_get_number()| after resolving {tab}; invalid windows return 0 in Vimscript' , 13692} , 13693} , 13694win_gettype ={ 13695args ={ 0 , 1 } , 13696base =1 , 13697desc =[=[ 13698Gets the type of the given window, or current window if {nr} 13699is omitted: 13700- (empty) Normal window 13701- "autocmd" Internal "context-switch" window. 13702- "command" Command-line window |cmdwin| 13703- "loclist" |location-list-window| 13704- "popup" Floating window |api-floatwin| 13705- "preview" Preview window |preview-window| 13706- "quickfix" |quickfix-window| 13707- "unknown" Window {nr} not found 13708 13709See also the 'buftype' option. 13710 13711]=] , 13712name ='win_gettype' , 13713params ={ { 'nr' , 'integer' } } , 13714returns ="'autocmd'|'command'|''|'loclist'|'popup'|'preview'|'quickfix'|'unknown'" , 13715signature ='win_gettype([{nr}])' , 13716} , 13717win_gotoid ={ 13718args =1 , 13719base =1 , 13720desc =[=[ 13721Go to |window-ID| {expr}. May change the current tabpage. 13722Return TRUE if successful, FALSE if the window cannot be 13723found. 13724 13725]=] , 13726name ='win_gotoid' , 13727params ={ { 'expr' , 'integer' } } , 13728returns ='0|1' , 13729signature ='win_gotoid({expr})' , 13730see_lua ={ '|nvim_set_current_win()|; invalid IDs error instead of returning FALSE' } , 13731} , 13732win_id2tabwin ={ 13733args =1 , 13734base =1 , 13735desc =[=[ 13736Return [tabnr, winnr] for window with |window-ID| {expr}, where 13737tabnr is the |tabpage-number| and winnr is the |window-number|. 13738Return [0, 0] if the window cannot be found. 13739 13740]=] , 13741name ='win_id2tabwin' , 13742params ={ { 'expr' , 'integer' } } , 13743signature ='win_id2tabwin({expr})' , 13744see_lua ={ 13745'|nvim_win_get_tabpage()| and |nvim_win_get_number()| for valid windows; invalid IDs error instead of returning `[0, 0]`' , 13746} , 13747} , 13748win_id2win ={ 13749args =1 , 13750base =1 , 13751desc =[=[ 13752Return the |window-number| of for the given |window-ID| {expr}. 13753Return 0 if the window cannot be found in the current tabpage. 13754 13755]=] , 13756name ='win_id2win' , 13757params ={ { 'expr' , 'integer' } } , 13758returns ='integer' , 13759signature ='win_id2win({expr})' , 13760see_lua ={ 13761'|nvim_win_get_number()| for valid windows; windows outside the current tabpage and invalid IDs differ' , 13762} , 13763} , 13764win_move_separator ={ 13765args =2 , 13766base =1 , 13767desc =[=[ 13768Move window {nr}'s vertical separator (i.e., the right border) 13769by {offset} columns, as if being dragged by the mouse. {nr} 13770is a |window-number| or |window-ID|. A positive {offset} 13771moves right and a negative {offset} moves left. Moving a 13772window's vertical separator will change the width of the 13773window and the width of other windows adjacent to the vertical 13774separator. The magnitude of movement may be smaller than 13775specified (e.g., as a consequence of maintaining 13776'winminwidth'). Returns TRUE if the window can be found and 13777FALSE otherwise. 13778This will fail for the rightmost window and a full-width 13779window, since it has no separator on the right. 13780Only works for the current tabpage. *E1308* 13781 13782]=] , 13783name ='win_move_separator' , 13784params ={ { 'nr' , 'integer' } , { 'offset' , 'integer' } } , 13785signature ='win_move_separator({nr}, {offset})' , 13786} , 13787win_move_statusline ={ 13788args =2 , 13789base =1 , 13790desc =[=[ 13791Move window {nr}'s status line (i.e., the bottom border) by 13792{offset} rows, as if being dragged by the mouse. {nr} is a 13793|window-number| or |window-ID|. A positive {offset} moves 13794down and a negative {offset} moves up. Moving a window's 13795status line will change the height of the window and the 13796height of other windows adjacent to the status line. The 13797magnitude of movement may be smaller than specified (e.g., as 13798a consequence of maintaining 'winminheight'). Returns TRUE if 13799the window can be found and FALSE otherwise. 13800Only works for the current tabpage. 13801 13802]=] , 13803name ='win_move_statusline' , 13804params ={ { 'nr' , 'integer' } , { 'offset' , 'integer' } } , 13805signature ='win_move_statusline({nr}, {offset})' , 13806} , 13807win_screenpos ={ 13808args =1 , 13809base =1 , 13810desc =[=[ 13811Return the screen position of window {nr} as a list with two 13812numbers: [row, col]. The first window always has position 13813[1, 1], unless there is a tabline, then it is [2, 1]. 13814{nr} is a |window-number| or |window-ID|. Use zero for the 13815current window. 13816Returns [0, 0] if the window cannot be found. 13817]=] , 13818name ='win_screenpos' , 13819params ={ { 'nr' , 'integer' } } , 13820signature ='win_screenpos({nr})' , 13821see_lua ={ 13822'|nvim_win_get_position()| and add 1 to row and col; invalid-window semantics differ' , 13823} , 13824} , 13825win_splitmove ={ 13826args ={ 2 , 3 } , 13827base =1 , 13828desc =[=[ 13829Temporarily switch to window {target}, then move window {nr} 13830to a new split adjacent to {target}. 13831Unlike commands such as |:split|, no new windows are created 13832(the |window-ID| of window {nr} is unchanged after the move). 13833 13834Both {nr} and {target} are a |window-number| or |window-ID|. 13835Both must be in the current tabpage. 13836 13837Returns zero for success, non-zero for failure. 13838 13839{options} is a |Dictionary| with the following optional entries: 13840"vertical" When TRUE, the split is created vertically, 13841like with |:vsplit|. 13842"rightbelow" When TRUE, the split is made below or to the 13843right (if vertical). When FALSE, it is done 13844above or to the left (if vertical). When not 13845present, the values of 'splitbelow' and 13846'splitright' are used. 13847 13848]=] , 13849name ='win_splitmove' , 13850params ={ { 'nr' , 'integer' } , { 'target' , 'integer' } , { 'options' , 'table' } } , 13851signature ='win_splitmove({nr}, {target} [, {options}])' , 13852} , 13853winbufnr ={ 13854args =1 , 13855base =1 , 13856desc =[=[ 13857Returns the buffer number associated with window {nr} 13858(|window-number| or |window-ID|). 13859When {nr} is zero, the number of the buffer in the current 13860window is returned. 13861When window {nr} doesn't exist, -1 is returned. 13862Example: >vim 13863echo "The file in the current window is " .. bufname(winbufnr(0)) 13864< 13865]=] , 13866name ='winbufnr' , 13867params ={ { 'nr' , 'integer' } } , 13868returns ='integer' , 13869signature ='winbufnr({nr})' , 13870see_lua ={ '|nvim_win_get_buf()|' } , 13871} , 13872wincol ={ 13873desc =[=[ 13874Returns the virtual column of the cursor in the window. 13875This is counting screen cells from the left side of the 13876window. The leftmost column is one. 13877]=] , 13878name ='wincol' , 13879params ={} , 13880returns ='integer' , 13881signature ='wincol()' , 13882} , 13883windowsversion ={ 13884desc =[=[ 13885Returns the Windows OS version as a String. E.g, Windows 10 13886is "10.0", Windows 8 is "6.2", Windows XP is "5.1". For 13887non-MS-Windows systems the result is an empty string. 13888 13889Lua: see |uv.os_uname()|. 13890]=] , 13891fast =true , 13892name ='windowsversion' , 13893params ={} , 13894returns ='string' , 13895signature ='windowsversion()' , 13896} , 13897winheight ={ 13898args =1 , 13899base =1 , 13900desc =[=[ 13901Gets the height of |window-ID| {nr} (zero for "current 13902window"), excluding any 'winbar' and 'statusline'. Returns -1 13903if window {nr} doesn't exist. An existing window always has 13904a height of zero or more. 13905 13906Examples: >vim 13907echo "Current window has " .. winheight(0) .. " lines." 13908< 13909]=] , 13910name ='winheight' , 13911params ={ { 'nr' , 'integer' } } , 13912returns ='integer' , 13913signature ='winheight({nr})' , 13914see_lua =false , 13915} , 13916winlayout ={ 13917args ={ 0 , 1 } , 13918base =1 , 13919desc =[=[ 13920Returns the layout of windows in a tabpage as a nested List. 13921 13922Without {tabnr} use the current tabpage, otherwise the tabpage 13923with number {tabnr}. If the tabpage {tabnr} is not found, 13924returns an empty list. 13925 13926For a leaf window, it returns: > 13927["leaf", {winid}] 13928< 13929For horizontally split windows, which form a column, it 13930returns: > 13931["col", [{nested list of windows}]] 13932<For vertically split windows, which form a row, it returns: > 13933["row", [{nested list of windows}]] 13934< 13935Example: >vim 13936" Only one window in the tabpage 13937echo winlayout() 13938< > 13939['leaf', 1000] 13940< >vim 13941" Two horizontally split windows 13942echo winlayout() 13943< > 13944['col', [['leaf', 1000], ['leaf', 1001]]] 13945< >vim 13946" The second tabpage, with three horizontally split 13947" windows, with two vertically split windows in the 13948" middle window 13949echo winlayout(2) 13950< > 13951['col', [['leaf', 1002], ['row', [['leaf', 1003], 13952['leaf', 1001]]], ['leaf', 1000]]] 13953< 13954]=] , 13955name ='winlayout' , 13956params ={ { 'tabnr' , 'integer' } } , 13957returns ='vim.fn.winlayout.ret' , 13958signature ='winlayout([{tabnr}])' , 13959} , 13960winline ={ 13961desc =[=[ 13962Returns the screen line of the cursor in the window. This is 13963counting screen lines from the top of the window. The first 13964line is one. 13965If the cursor was moved the view on the file will be updated 13966first, this may cause a scroll. 13967]=] , 13968name ='winline' , 13969params ={} , 13970returns ='integer' , 13971signature ='winline()' , 13972} , 13973winnr ={ 13974args ={ 0 , 1 } , 13975base =1 , 13976desc =[=[ 13977Returns the number of the current window. The top window has 13978number 1. Returns zero for a hidden or non |focusable| 13979window, unless it is the current window. 13980 13981The optional argument {arg} supports the following values: 13982$ the number of the last window (the window 13983count). 13984# the number of the last accessed window (where 13985|CTRL-W_p| goes to). If there is no previous 13986window or it is in another tabpage, 0 is 13987returned. May refer to the current window in 13988some cases (e.g. when evaluating 'statusline' 13989expressions). 13990{N}j the number of the Nth window below the 13991current window (where |CTRL-W_j| goes to). 13992{N}k the number of the Nth window above the current 13993window (where |CTRL-W_k| goes to). 13994{N}h the number of the Nth window left of the 13995current window (where |CTRL-W_h| goes to). 13996{N}l the number of the Nth window right of the 13997current window (where |CTRL-W_l| goes to). 13998The number can be used with |CTRL-W_w| and ":wincmd w" 13999|:wincmd|. 14000When {arg} is invalid an error is given and zero is returned. 14001Also see |tabpagewinnr()| and |win_getid()|. 14002Examples: >vim 14003let window_count = winnr('$') 14004let prev_window = winnr('#') 14005let wnum = winnr('3k') 14006< 14007]=] , 14008name ='winnr' , 14009params ={ { 'arg' , 'string|integer' } } , 14010returns ='integer' , 14011signature ='winnr([{arg}])' , 14012see_lua ={ 14013'|nvim_win_get_number()| with |nvim_get_current_win()| for the current window, or |nvim_tabpage_list_wins()| with |nvim_get_current_tabpage()| for "$"; "#", motion args, and hidden windows differ' , 14014} , 14015} , 14016winrestcmd ={ 14017desc =[=[ 14018Returns a sequence of |:resize| commands that should restore 14019the current window sizes. Only works properly when no windows 14020are opened or closed and the current window and tabpage is 14021unchanged. 14022Example: >vim 14023let cmd = winrestcmd() 14024call MessWithWindowSizes() 14025exe cmd 14026< 14027]=] , 14028name ='winrestcmd' , 14029params ={} , 14030returns ='string' , 14031signature ='winrestcmd()' , 14032} , 14033winrestview ={ 14034args =1 , 14035base =1 , 14036desc =[=[ 14037Uses the |Dictionary| returned by |winsaveview()| to restore 14038the view of the current window. 14039Note: The {dict} does not have to contain all values, that are 14040returned by |winsaveview()|. If values are missing, those 14041settings won't be restored. So you can use: >vim 14042call winrestview({'curswant': 4}) 14043< 14044This will only set the curswant value (the column the cursor 14045wants to move on vertical movements) of the cursor to column 5 14046(yes, that is 5), while all other settings will remain the 14047same. This is useful, if you set the cursor position 14048manually. 14049 14050If you have changed the values the result is unpredictable. 14051If the window size changed the result won't be the same. 14052 14053]=] , 14054name ='winrestview' , 14055params ={ { 'dict' , 'vim.fn.winrestview.dict' } } , 14056signature ='winrestview({dict})' , 14057} , 14058winsaveview ={ 14059desc =[=[ 14060Returns a |Dictionary| that contains information to restore 14061the view of the current window. Use |winrestview()| to 14062restore the view. 14063This is useful if you have a mapping that jumps around in the 14064buffer and you want to go back to the original view. 14065This does not save fold information. Use the 'foldenable' 14066option to temporarily switch off folding, so that folds are 14067not opened when moving around. This may have side effects. 14068The return value includes: 14069lnum cursor line number 14070col cursor column (Note: the first column 14071zero, as opposed to what |getcurpos()| 14072returns) 14073coladd cursor column offset for 'virtualedit' 14074curswant column for vertical movement (Note: 14075the first column is zero, as opposed 14076to what |getcurpos()| returns). After 14077|$| command it will be a very large 14078number equal to |v:maxcol|. 14079topline first line in the window 14080topfill filler lines, only in diff mode 14081leftcol first column displayed; only used when 14082'wrap' is off 14083skipcol columns skipped 14084Note that no option values are saved. 14085]=] , 14086name ='winsaveview' , 14087params ={} , 14088signature ='winsaveview()' , 14089returns ='vim.fn.winsaveview.ret' , 14090} , 14091winwidth ={ 14092args =1 , 14093base =1 , 14094desc =[=[ 14095Gets the width of |window-ID| {nr} (zero for "current 14096window"), including columns (|sign-column|, 'statuscolumn', 14097etc.). Returns -1 if window {nr} doesn't exist. An existing 14098window always has a width of zero or more. 14099 14100Example: >vim 14101echo "Current window has " .. winwidth(0) .. " columns." 14102if winwidth(0) <= 50 1410350 wincmd | 14104endif 14105< 14106To get the buffer "viewport", use |getwininfo()|: >vim 14107:echo getwininfo(win_getid())[0].width - getwininfo(win_getid())[0].textoff 14108< 14109To get the Nvim screen size, see the 'columns' option. 14110]=] , 14111name ='winwidth' , 14112params ={ { 'nr' , 'integer' } } , 14113returns ='integer' , 14114signature ='winwidth({nr})' , 14115see_lua =false , 14116} , 14117wordcount ={ 14118desc =[=[ 14119Returns a dictionary of byte/chars/word statistics for the 14120current buffer. This is the same info provided by |g_CTRL-G|. 14121The return value includes: 14122bytes Number of bytes in the buffer 14123chars Number of chars in the buffer 14124words Number of words in the buffer 14125cursor_bytes Number of bytes before cursor position 14126(not in Visual mode) 14127cursor_chars Number of chars before cursor position 14128(not in Visual mode) 14129cursor_words Number of words before cursor position 14130(not in Visual mode) 14131visual_bytes Number of bytes visually selected 14132(only in Visual mode) 14133visual_chars Number of chars visually selected 14134(only in Visual mode) 14135visual_words Number of words visually selected 14136(only in Visual mode) 14137]=] , 14138name ='wordcount' , 14139params ={} , 14140signature ='wordcount()' , 14141} , 14142writefile ={ 14143args ={ 2 , 3 } , 14144base =1 , 14145desc =[=[ 14146Writes {data} to file {fname}. 14147 14148- When {data} is a |Blob| its bytes are written unmodified 14149(even if binary mode "b" is not specified). 14150- When {data} is a Lua string, it is treated as a blob. 14151- When {data} is a |List|, each list item is treated as a text 14152line (terminated with a newline). Each list item must be 14153a String or Number. 14154- Any NL (newline) chars in the line are treated as a NUL 14155character. (This is a workaround to allow Vimscript to 14156write binary data, and is irrelevant for Lua, which should 14157just pass a string instead.) 14158 14159{flags} must be a String. These characters are recognized: 14160 14161'b' Binary mode is used: There will not be a NL after the 14162last list item. An empty item at the end does cause the 14163last line in the file to end in a NL. 14164 14165'a' Append mode is used, lines are appended to the file: >vim 14166call writefile(["foo"], "event.log", "a") 14167call writefile(["bar"], "event.log", "a") 14168< 14169'D' Delete the file when the current function ends. This 14170works like: >vim 14171defer delete({fname}) 14172< Fails when not in a function. Also see |:defer|. 14173 14174's' fsync() is called after writing the file. This flushes 14175the file to disk, if possible. This takes more time but 14176avoids losing the file if the system crashes. 14177 14178'S' fsync() is not called, even when 'fsync' is set. 14179 14180When {flags} does not contain "S" or "s" then fsync() is 14181called if the 'fsync' option is set. 14182 14183An existing file is overwritten, if possible. 14184 14185When the write fails -1 is returned, otherwise 0. There is an 14186error message if the file can't be created or when writing 14187fails. 14188 14189Also see |readfile()|. 14190To copy a file byte for byte: >vim 14191let fl = readfile("foo", "b") 14192call writefile(fl, "foocopy", "b") 14193< 14194 14195]=] , 14196name ='writefile' , 14197params ={ { 'data' , 'any' } , { 'fname' , 'string' } , { 'flags' , 'string' } } , 14198signature ='writefile({data}, {fname} [, {flags}])' , 14199} , 14200xor ={ 14201args =2 , 14202base =1 , 14203desc =[=[ 14204Bitwise XOR on the two arguments. The arguments are converted 14205to a number. A List, Dict or Float argument causes an error. 14206Also see `and()` and `or()`. 14207Example: >vim 14208let bits = xor(bits, 0x80) 14209< 14210]=] , 14211name ='xor' , 14212params ={ { 'expr' , 'integer' } , { 'expr' , 'integer' } } , 14213returns ='integer' , 14214signature ='xor({expr}, {expr})' , 14215see_lua ={ '|bit.bxor()|' } , 14216} , 14217} 14218 14219return M